Documentation ¶
Overview ¶
Package ssh provides functionality to execute commands on remote targets using SSH. The library also provides standardized file upload and download methods that will rely on the SFTP protocol.
Index ¶
- type Connector
- type Environment
- func (env *Environment) Exec(cmd string, disown bool) (string, error)
- func (env *Environment) GetRemoteHost() string
- func (env *Environment) Include(options ...func(*Environment)) script.Option
- func (env *Environment) Library(options ...func(*Environment)) script.Library
- func (env *Environment) SetUser(user string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector interface {
Connect(remoteHost string, filter func([]ssh.ClientConfig) []ssh.ClientConfig) (*ssh.Client, error)
}
Connector provides an ssh client connected to a remote host.
type Environment ¶
type Environment struct { *script.Environment Connector Connector RemoteHost string RemoteUser string // contains filtered or unexported fields }
Environment used to configure the behaviour of calls to the ssh library.
func (*Environment) Exec ¶
func (env *Environment) Exec(cmd string, disown bool) (string, error)
Exec a command on the remote system using an underlying ssh session.
@callable: ssh.exec @param: cmd @string @param: disown @?string @retval: output @string @retval: err @Error
@usage: output, err = ssh.exec("/bin/bash -c 'ls -al'")
func (*Environment) GetRemoteHost ¶ added in v0.4.0
func (env *Environment) GetRemoteHost() string
GetRemoteHost will return the remote host being used by the worker to connect to.
@callable: ssh.getRemoteHost @retval: host @String
@usage: host = ssh.getRemoteHost()
func (*Environment) Include ¶
func (env *Environment) Include(options ...func(*Environment)) script.Option
Include the ssh library in a script environment.
func (*Environment) Library ¶
func (env *Environment) Library(options ...func(*Environment)) script.Library
Library prepares a new ssh library for use within a script environment.
func (*Environment) SetUser ¶ added in v0.4.0
func (env *Environment) SetUser(user string)
SetUser sets the RemoteUser attribute to be used in the outgoing SSH Connection. WARNING: MUST BE CALLED BEFORE OTHER SSH CALLS TO WORK.
@callable: ssh.setUser @param: user @string
@usage: ssh.setUser("root")