Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func ConnectWithAgent(host, username string) (*Client, error)
- func ConnectWithAgentTimeout(host, username string, timeout time.Duration) (*Client, error)
- 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 (c *Client) Close() error
- func (c *Client) Download(remote, local string) error
- func (c *Client) DownloadAsBytes(remote string) ([]byte, error)
- func (c *Client) Exec(cmd string) ([]byte, error)
- func (c *Client) ExecSudo(cmd, passwd string) ([]byte, error)
- func (c *Client) ReadAll(filepath string) ([]byte, error)
- func (c *Client) Remove(path string) error
- func (c *Client) RemoveDirectory(path string) error
- func (c *Client) SFTPClient() (*sftp.Client, error)
- func (c *Client) Upload(local, remote string) error
- func (c *Client) UploadBytes(local []byte, remote string) error
Constants ¶
const DefaultTimeout = 30 * time.Second
Variables ¶
var HostKeyCallback = ssh.InsecureIgnoreHostKey()
Set a default HostKeyCallback variable. This may not be desireable for some environments.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func ConnectWithAgent ¶
Connect to an ssh agent. If username is empty simplessh will attempt to get the current user. The windows implementation uses a different library which expects pageant to be running.
func ConnectWithAgentTimeout ¶
Connect to an ssh agent with a custom timeout. If username is empty simplessh will attempt to get the current user. The windows implementation uses a different library which expects pageant to be running.
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 (*Client) DownloadAsBytes ¶
Download a file from the remote server
func (*Client) ExecSudo ¶
Execute cmd via sudo. Do not include the sudo command in the cmd string. For example: Client.ExecSudo("uptime", "password"). If you are using passwordless sudo you can use the regular Exec() function.
func (*Client) RemoveDirectory ¶
Remove a directory from the remote server
func (*Client) SFTPClient ¶
Return an sftp client. The client needs to be closed when it's no longer needed.