Documentation ¶
Overview ¶
Package sssh (simple ssh) provides a wrapper that simplifies creating an ssh session (using golang.org/x/crypto/ssh).
The package supports creating a session, authenticated via username/password or username/private key, with optional socks5 proxy or jump proxy.
This is roughly equivalent to an ssh connection with the following options:
Host hostname ProxyCommand /usr/bin/nc -x proxyserver:port %h %p User username IdentityFile privatekey-file
Index ¶
- Variables
- func Copy(client *ssh.Client, dest, src string, size int64, perm os.FileMode, ...) error
- func CopyFile(client *ssh.Client, dest, src string) error
- func NewClient(host string, options ...ConnectOption) (*ssh.Client, error)
- func NewSession(host string, options ...ConnectOption) (*ssh.Session, error)
- func Shell(client *ssh.Client) error
- type ConnectOption
- func Banner(callback ssh.BannerCallback) ConnectOption
- func JumpProxy(proxy string, options ...ConnectOption) ConnectOption
- func KeyboardInteractive(cb KeyboardInteractiveChallenge) ConnectOption
- func Password(password string) ConnectOption
- func PrivateKey(key []byte) ConnectOption
- func PrivateKeyFile(keyFile string) ConnectOption
- func SocksProxy(proxy string) ConnectOption
- func Timeout(t time.Duration) ConnectOption
- func User(user string) ConnectOption
- type KeyboardInteractiveChallenge
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func NewClient ¶
func NewClient(host string, options ...ConnectOption) (*ssh.Client, error)
NewClient creates a new ssh client/connection to host (host:port) with the specified options
func NewSession ¶
func NewSession(host string, options ...ConnectOption) (*ssh.Session, error)
NewSession creates a new ssh session/connection to host (host:port) with the specified options
Types ¶
type ConnectOption ¶
type ConnectOption func(c *sshConfig) error
ConnectOption is the common type for NewSession options
func Banner ¶
func Banner(callback ssh.BannerCallback) ConnectOption
Banner sets the banner callback, called when the remote host sends the banner
func JumpProxy ¶
func JumpProxy(proxy string, options ...ConnectOption) ConnectOption
JumpProxy configures the session to jump through one proxy server
func KeyboardInteractive ¶
func KeyboardInteractive(cb KeyboardInteractiveChallenge) ConnectOption
KeyboardInteractive sets the authentication mode to keyboar/interactive
func Password ¶
func Password(password string) ConnectOption
Password sets the user password for authentication
func PrivateKey ¶
func PrivateKey(key []byte) ConnectOption
PrivateKey sets the private key for authentication
func PrivateKeyFile ¶
func PrivateKeyFile(keyFile string) ConnectOption
PrivateKeyFile sets the private key file for authentication
func SocksProxy ¶
func SocksProxy(proxy string) ConnectOption
SocksProxy sets the (socks5) proxy address (host:port)
type KeyboardInteractiveChallenge ¶
type KeyboardInteractiveChallenge = ssh.KeyboardInteractiveChallenge
type KeyboardInteractiveChallenge func(user, instruction string, questions []string, echos []bool) (answers []string, err error)