Documentation ¶
Overview ¶
Package sshclient implements an SSH client.
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) Cmd(cmd string) *RemoteScript
- func (c *Client) Dial(network, addr string, config *ssh.ClientConfig) (*Client, error)
- func (c *Client) Script(script string) *RemoteScript
- func (c *Client) ScriptFile(fname string) *RemoteScript
- func (c *Client) Shell() *RemoteShell
- func (c *Client) Terminal(config *TerminalConfig) *RemoteShell
- func (c *Client) UnderlyingClient() *ssh.Client
- type RemoteScript
- type RemoteShell
- type TerminalConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client implements an SSH client that supports running commands and scripts remotely.
func Dial ¶
func Dial(network, addr string, config *ssh.ClientConfig) (*Client, error)
Dial starts a client connection to the given SSH server. This wraps ssh.Dial.
func DialWithKey ¶
DialWithKey starts a client connection to the given SSH server with key authmethod.
func DialWithKeyWithPassphrase ¶
DialWithKeyWithPassphrase same as DialWithKey but with a passphrase to decrypt the private key
func DialWithPasswd ¶
DialWithPasswd starts a client connection to the given SSH server with passwd authmethod.
func (*Client) Cmd ¶
func (c *Client) Cmd(cmd string) *RemoteScript
Cmd creates a RemoteScript that can run the command on the client. The cmd string is split on newlines and each line is executed separately.
func (*Client) Script ¶
func (c *Client) Script(script string) *RemoteScript
Script creates a RemoteScript that can run the script on the client.
func (*Client) ScriptFile ¶
func (c *Client) ScriptFile(fname string) *RemoteScript
ScriptFile creates a RemoteScript that can read a local script file and run it remotely on the client.
func (*Client) Shell ¶
func (c *Client) Shell() *RemoteShell
Shell create a noninteractive shell on client.
func (*Client) Terminal ¶
func (c *Client) Terminal(config *TerminalConfig) *RemoteShell
Terminal create a interactive shell on client.
func (*Client) UnderlyingClient ¶
UnderlyingClient get the underlying client.
type RemoteScript ¶
type RemoteScript struct {
// contains filtered or unexported fields
}
A RemoteScript represents script that can be run remotely.
func (*RemoteScript) Cmd ¶
func (rs *RemoteScript) Cmd(cmd string) *RemoteScript
Cmd appends a command to the RemoteScript.
func (*RemoteScript) Output ¶
func (rs *RemoteScript) Output() ([]byte, error)
Output runs the script on the client and returns its standard output.
func (*RemoteScript) Run ¶
func (rs *RemoteScript) Run() error
Run runs the script on the client.
The returned error is nil if the command runs, has no problems copying stdin, stdout, and stderr, and exits with a zero exit status.
func (*RemoteScript) SetStdio ¶
func (rs *RemoteScript) SetStdio(stdout, stderr io.Writer) *RemoteScript
SetStdio specifies where its standard output and error data will be written.
func (*RemoteScript) SmartOutput ¶
func (rs *RemoteScript) SmartOutput() ([]byte, error)
SmartOutput runs the script on the client. On success, its standard ouput is returned. On error, its standard error is returned.
type RemoteShell ¶
type RemoteShell struct {
// contains filtered or unexported fields
}
A RemoteShell represents a login shell on the client.
func (*RemoteShell) SetStdio ¶
func (rs *RemoteShell) SetStdio(stdin io.Reader, stdout, stderr io.Writer) *RemoteShell
SetStdio specifies where the its standard output and error data will be written.
func (*RemoteShell) Start ¶
func (rs *RemoteShell) Start() error
Start starts a remote shell on client.
type TerminalConfig ¶
type TerminalConfig struct { Term string Height int Weight int Modes ssh.TerminalModes }
A TerminalConfig represents the configuration for an interactive shell session.