Documentation ¶
Index ¶
- func AddEnv(script string, env []string) (string, error)
- type SSHClient
- func (s *SSHClient) Close() error
- func (s *SSHClient) Dial() error
- func (s *SSHClient) DialContext(ctx context.Context) error
- func (s *SSHClient) ExecScript(script string) error
- func (s *SSHClient) Shell() error
- func (s *SSHClient) StderrPipe() (io.Reader, error)
- func (s *SSHClient) StdoutPipe() (io.Reader, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddEnv ¶
AddEnv takes a script and prepends it with export lines from the env variable slice. Entries in env should have a VAR=val syntax Note that this currently does only a limited number of checks There is a ssh.session.Setenv(), but usually ssh, for good reasons, does only allow to set a limited set of variables/no user variables at all.
Types ¶
type SSHClient ¶
type SSHClient struct {
// contains filtered or unexported fields
}
SSHClient represents a high level ssh client
func NewSSHClient ¶
func NewSSHClient(hostPort string, sshconfig ssh.ClientConfig) *SSHClient
NewSSHClient returns a high level ssh client
func (*SSHClient) Dial ¶ added in v0.2.0
Dial creates an ssh client as well as its session After a successful call to Dial(), one should also always call Close()
func (*SSHClient) DialContext ¶ added in v0.3.0
DialContext creates an ssh client as well as its session After a successful call to DialContext(), one should also always call Close() Note that this allows one to return early by canceling the context, but ExecScript() might still execute on the remote host. Example: "sleep 20 && touch /tmp/foo" and cancel after 10s. You might still find /tmp/foo on the host!
func (*SSHClient) ExecScript ¶
ExecScript executes a (shell) script line by line. After return, you can not re-use the sshclient
func (*SSHClient) Shell ¶
Shell executes an interactive ssh shell After return, you can not re-use the sshclient
func (*SSHClient) StderrPipe ¶
StderrPipe creates an ssh.session if it does not exist and calls StderrPipe on it.