Documentation ¶
Overview ¶
Package ssh is a helper for working with ssh in go.
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 Dial(ctx context.Context, config Config) (*ssh.Client, error)
- func GenKeyPair() (string, string, error)
- func MakeHostKeyCallback(insecure bool, l Logger) (ssh.HostKeyCallback, 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 SFTP(ctx context.Context, cfg Config) (*sftp.Client, error)
- func Shell(ctx context.Context, config Config, stdin io.Reader, stdout, stderr io.Writer, ...) error
- type Client
- type Config
- type ExitError
- type HTTPConnectProxy
- type Logger
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 MakeHostKeyCallback ¶ added in v0.6.0
func MakeHostKeyCallback(insecure bool, l Logger) (ssh.HostKeyCallback, error)
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 Client struct { Cfg Config Session *ssh.Session Conn *ssh.Client Stdin io.WriteCloser Stdout io.Reader Stderr io.Reader sync.Mutex // contains filtered or unexported fields }
func StartCommand ¶ added in v0.6.0
StartCommand starts the specified command without waiting for it to finish. You have to call the Wait function for that.
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 HostKey ssh.HostKeyCallback // callback for verifying server keys, ssh.InsecureIgnoreHostKey by default HTTPProxy *url.URL }
func (Config) GetHostKeyCallback ¶ added in v0.6.0
func (cfg Config) GetHostKeyCallback() ssh.HostKeyCallback
func (Config) ToNatives ¶ added in v0.6.3
func (cfg Config) ToNatives() []*ssh.ClientConfig
type ExitError ¶
ExitError is a convenience wrapper for (crypto/ssh).ExitError type.
type HTTPConnectProxy ¶ added in v0.7.0
type HTTPConnectProxy struct { HTTPS bool Host string HaveAuth bool Username string Password string }
func NewHTTPConnectProxy ¶ added in v0.7.0
func NewHTTPConnectProxy(uri *url.URL) *HTTPConnectProxy