sshclient

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEnv

func AddEnv(script string, env []string) (string, error)

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) Close added in v0.2.0

func (s *SSHClient) Close() error

Close closes the underlying ssh session and client

func (*SSHClient) Dial added in v0.2.0

func (s *SSHClient) Dial() error

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

func (s *SSHClient) DialContext(ctx context.Context) error

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

func (s *SSHClient) ExecScript(script string) error

ExecScript executes a (shell) script line by line. After return, you can not re-use the sshclient

func (*SSHClient) Shell

func (s *SSHClient) Shell() error

Shell executes an interactive ssh shell After return, you can not re-use the sshclient

func (*SSHClient) StderrPipe

func (s *SSHClient) StderrPipe() (io.Reader, error)

StderrPipe creates an ssh.session if it does not exist and calls StderrPipe on it.

func (*SSHClient) StdoutPipe

func (s *SSHClient) StdoutPipe() (io.Reader, error)

StdoutPipe creates an ssh.session if it does not exist and calls StdoutPipe on it.

Jump to

Keyboard shortcuts

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