until

package
v0.0.0-...-98e0aed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

Variables

View Source
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

type Client struct {
	SSHClient *ssh.Client
}

func ConnectWithAgent

func ConnectWithAgent(host, username string) (*Client, error)

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

func ConnectWithAgentTimeout(host, username string, timeout time.Duration) (*Client, error)

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

func ConnectWithKey(host, username, privKey string) (*Client, error)

Connect with a private key. If username is empty simplessh will attempt to get the current user.

func ConnectWithKeyFile

func ConnectWithKeyFile(host, username, privKeyPath string) (*Client, error)

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

func ConnectWithKeyTimeout(host, username, privKey string, timeout time.Duration) (*Client, error)

Connect with a private key with a custom timeout. If username is empty simplessh will attempt to get the current user.

func ConnectWithPassword

func ConnectWithPassword(host, username, pass string) (*Client, error)

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) Close

func (c *Client) Close() error

Close the underlying SSH connection

func (*Client) Download

func (c *Client) Download(remote, local string) error

Download a file from the remote server

func (*Client) Exec

func (c *Client) Exec(cmd string) ([]byte, error)

Execute cmd on the remote host and return stderr and stdout

func (*Client) ExecSudo

func (c *Client) ExecSudo(cmd, passwd string) ([]byte, error)

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) ReadAll

func (c *Client) ReadAll(filepath string) ([]byte, error)

Read a remote file and return the contents.

func (*Client) Remove

func (c *Client) Remove(path string) error

Remove a file from the remote server

func (*Client) RemoveDirectory

func (c *Client) RemoveDirectory(path string) error

Remove a directory from the remote server

func (*Client) SFTPClient

func (c *Client) SFTPClient() (*sftp.Client, error)

Return an sftp client. The client needs to be closed when it's no longer needed.

func (*Client) Upload

func (c *Client) Upload(local, remote string) error

Upload a file to the remote server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL