Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SingleKnownHost ¶
func SingleKnownHost() ssh.HostKeyCallback
SingleKnownHost is a simple HostKeyCallback that stores the host key in memory on the first callback. Future callbacks verify that the host key hasn't changed.
Types ¶
type Config ¶
type Config struct {
// ClientConfig is the standard SSH client config.
ssh.ClientConfig
// DialContext is used for opening TCP connections to the remote host. Defaults to a net.Dialer with 30s timeout.
DialContext func(ctx context.Context, network, addr string) (net.Conn, error)
}
Config contains configuration for connecting to remote hosts.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig is the default SSH client Config used by Dial.
type Connection ¶
Connection simplifies working with SSH connections for standard command execution and connection proxying. Use Dial to open a new Connection, and ensure to call Connection.Close() for cleanup.
func (*Connection) Run ¶
Run executes the given command on the remote host and returns stdout and stderr streams.
func (*Connection) RunWithStreams ¶
func (c *Connection) RunWithStreams(stdin io.Reader, stdout, stderr io.Writer, command string) error
RunWithStreams executes the given command on the remote host with the configured streams.
type Option ¶
Option is an option that can be passed to Dial for customizing the client Config.
func WithPrivateKey ¶
func WithPrivateKey(key *rsa.PrivateKey) Option
WithPrivateKey configures the client to authenticate using the given RSA private key.
func WithPrivateKeyBytes ¶
WithPrivateKeyBytes configures the client to authenticate using the given PEM encoded private key.
func WithProxyConnection ¶
func WithProxyConnection(conn *Connection) Option
WithProxyConnection configures the client to open the new TCP connection to the remote host via another open SSH connection.