ssh

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2021 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package ssh implements the SSH communicator. Plugin maintainers should not import this package directly, instead using the tooling in the "packer-plugin-sdk/communicator" module.

Index

Constants

This section is empty.

Variables

View Source
var ErrHandshakeTimeout = fmt.Errorf("Timeout during SSH handshake")

ErrHandshakeTimeout is returned from New() whenever we're unable to establish an ssh connection within a certain timeframe. By default the handshake time- out period is 1 minute. You can change it with Config.HandshakeTimeout.

Functions

func BastionConnectFunc

func BastionConnectFunc(
	bProto string,
	bAddr string,
	bConf *ssh.ClientConfig,
	proto string,
	addr string) func() (net.Conn, error)

BastionConnectFunc is a convenience method for returning a function that connects to a host over a bastion connection.

func ConnectFunc

func ConnectFunc(network, addr string) func() (net.Conn, error)

ConnectFunc is a convenience method for returning a function that just uses net.Dial to communicate with the remote end that is suitable for use with the SSH communicator configuration.

func New

func New(address string, config *Config) (result *comm, err error)

Creates a new packersdk.Communicator implementation over SSH. This takes an already existing TCP connection and SSH configuration.

func PasswordKeyboardInteractive

func PasswordKeyboardInteractive(password string) ssh.KeyboardInteractiveChallenge

An implementation of ssh.KeyboardInteractiveChallenge that simply sends back the password for all questions. The questions are logged.

func ProxyConnectFunc

func ProxyConnectFunc(socksProxy string, socksAuth *proxy.Auth, network, addr string) func() (net.Conn, error)

ProxyConnectFunc is a convenience method for returning a function that connects to a host using SOCKS5 proxy

func ProxyServe

func ProxyServe(l net.Listener, done <-chan struct{}, dialer func() (net.Conn, error))

ProxyServe starts Accepting connections

Types

type Config

type Config struct {
	// The configuration of the Go SSH connection
	SSHConfig *ssh.ClientConfig

	// Connection returns a new connection. The current connection
	// in use will be closed as part of the Close method, or in the
	// case an error occurs.
	Connection func() (net.Conn, error)

	// Pty, if true, will request a pty from the remote end.
	Pty bool

	// DisableAgentForwarding, if true, will not forward the SSH agent.
	DisableAgentForwarding bool

	// HandshakeTimeout limits the amount of time we'll wait to handshake before
	// saying the connection failed.
	HandshakeTimeout time.Duration

	// UseSftp, if true, sftp will be used instead of scp for file transfers
	UseSftp bool

	// KeepAliveInterval sets how often we send a channel request to the
	// server. A value < 0 disables.
	KeepAliveInterval time.Duration

	// Timeout is how long to wait for a read or write to succeed.
	Timeout time.Duration

	Tunnels []TunnelSpec
}

Config is the structure used to configure the SSH communicator.

type TunnelDirection

type TunnelDirection int

TunnelDirection is the supported tunnel directions

const (
	UnsetTunnel TunnelDirection = iota
	RemoteTunnel
	LocalTunnel
)

type TunnelSpec

type TunnelSpec struct {
	Direction   TunnelDirection
	ListenType  string
	ListenAddr  string
	ForwardType string
	ForwardAddr string
}

TunnelSpec represents a request to map a port on one side of the SSH connection to the other

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL