Documentation ¶
Overview ¶
Package ssh is a helper for working with ssh in go. The client implementation is a modified version of `docker/machine/libmachine/ssh/client.go` and only uses golang's native ssh client. It has also been improved to resize the tty accordingly. The key functions are meant to be used by either client or server and will generate/store keys if not found.
Index ¶
- func AuthCert(keyReader, certReader io.Reader) (ssh.AuthMethod, error)
- func AuthCertFile(keyFilename, certFilename string) (ssh.AuthMethod, error)
- func AuthKey(r io.Reader) (ssh.AuthMethod, error)
- func AuthKeyFile(keyFilename string) (ssh.AuthMethod, error)
- func AuthPassword(password string) ssh.AuthMethod
- func GenKeyPair() (string, string, error)
- func GetKeyPair(file string) (string, string, error)
- func Output(ctx context.Context, config Config, command string, stdout, stderr io.Writer) error
- func OutputWithPty(ctx context.Context, config Config, command string, stdout, stderr io.Writer) error
- func ParseCertificate(cert []byte) (*ssh.Certificate, error)
- func Shell(ctx context.Context, config Config, stdin io.Reader, stdout, stderr io.Writer, ...) error
- type Client
- type Config
- type ExitError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthCert ¶
func AuthCert(keyReader, certReader io.Reader) (ssh.AuthMethod, error)
AuthCert creates an AuthMethod for SSH certificate authentication from the key and certificate bytes.
func AuthCertFile ¶
func AuthCertFile(keyFilename, certFilename string) (ssh.AuthMethod, error)
AuthCertFile creates an AuthMethod for SSH certificate authentication from the key and certicate files.
func AuthKey ¶
func AuthKey(r io.Reader) (ssh.AuthMethod, error)
AuthKey creates an AuthMethod for SSH key authentication.
func AuthKeyFile ¶
func AuthKeyFile(keyFilename string) (ssh.AuthMethod, error)
AuthKey creates an AuthMethod for SSH key authentication from a key file.
func AuthPassword ¶
func AuthPassword(password string) ssh.AuthMethod
AuthPassword creates an AuthMethod for password authentication.
func GenKeyPair ¶
GenKeyPair make a pair of public and private keys for SSH access. Public key is encoded in the format for inclusion in an OpenSSH authorized_keys file. Private Key generated is PEM encoded
func GetKeyPair ¶
GetKeyPair will attempt to get the keypair from a file and will fail back to generating a new set and saving it to the file. Returns pub, priv, err
func OutputWithPty ¶ added in v0.5.0
func OutputWithPty(ctx context.Context, config Config, command string, stdout, stderr io.Writer) error
Output returns the output of the command run on the remote host as well as a pty.
func ParseCertificate ¶
func ParseCertificate(cert []byte) (*ssh.Certificate, error)
Types ¶
type Client ¶
type Config ¶
type Config struct { User string // username to connect as, required Host string // hostname to connect to, required ClientVersion string // ssh client version, "SSH-2.0-Go" by default Port int // port to connect to, 22 by default Auth []ssh.AuthMethod // authentication methods to use Timeout time.Duration // connect timeout, 30s by default DialRetry int // number of dial retries, 0 (no retries) by default HostKey ssh.HostKeyCallback // callback for verifying server keys, ssh.InsecureIgnoreHostKey by default }