Documentation ¶
Overview ¶
A simple abstraction around ssh and sftp libraries in go that extends sfreiberg's simplessh package to include ssh-agent support and separate output steams for command execution.
Index ¶
- Constants
- type Client
- func ConnectWithKey(host, username, privKey string) (*Client, error)
- func ConnectWithKeyFile(host, username, privKeyPath string) (*Client, error)
- func ConnectWithKeyFileTimeout(host, username, privKeyPath string, timeout time.Duration) (*Client, error)
- func ConnectWithKeyTimeout(host, username, privKey string, timeout time.Duration) (*Client, error)
- func ConnectWithPassword(host, username, pass string) (*Client, error)
- func ConnectWithPasswordTimeout(host, username, pass string, timeout time.Duration) (*Client, error)
- func ConnectWithSshAgent(host, username string) (*Client, error)
- func ConnectWithSshAgentTimeout(host, username string, timeout time.Duration) (*Client, error)
- func (c *Client) Close() error
- func (c *Client) Download(remote, local string) error
- func (c *Client) Exec(cmd string) ([]byte, error)
- func (c *Client) ExecWithOutputStreams(cmd string) ([]byte, []byte, error)
- func (c *Client) ReadAll(filepath string) ([]byte, error)
- func (c *Client) SFTPClient() (*sftp.Client, error)
- func (c *Client) Upload(local, remote string) error
Constants ¶
const DefaultTimeout = 30 * time.Second
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func ConnectWithKey ¶
Connect with a private key. If username is empty simplessh will attempt to get the current user.
func ConnectWithKeyFile ¶
Same as ConnectWithKeyFile but allows a custom timeout. If username is empty simplessh will attempt to get the current user.
func ConnectWithKeyFileTimeout ¶
func ConnectWithKeyFileTimeout(host, username, privKeyPath string, timeout time.Duration) (*Client, error)
Connect with a private key. If privKeyPath is an empty string it will attempt to use $HOME/.ssh/id_rsa. If username is empty simplessh will attempt to get the current user.
func ConnectWithKeyTimeout ¶
Connect with a private key with a custom timeout. If username is empty simplessh will attempt to get the current user.
func ConnectWithPassword ¶
Connect with a password. If username is empty simplessh will attempt to get the current user.
func ConnectWithPasswordTimeout ¶
func ConnectWithPasswordTimeout(host, username, pass string, timeout time.Duration) (*Client, error)
Same as ConnectWithPassword but allows a custom timeout. If username is empty simplessh will attempt to get the current user.
func ConnectWithSshAgent ¶
Connect with a ssh agent. If username is empty simplessh will attempt to get the current user.
func ConnectWithSshAgentTimeout ¶
Connect with a ssh agent with a custom timeout. If username is empty simplessh will attempt to get the current user.
func (*Client) ExecWithOutputStreams ¶
Execute cmd on the remote host and return stderr and stdout as separte streams
func (*Client) SFTPClient ¶
Return an sftp client. The client needs to be closed when it's no longer needed.