Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- type Credentials
- type KeyPair
- type MockSSHClient
- func (c *MockSSHClient) Connect() error
- func (c *MockSSHClient) Disconnect()
- func (c *MockSSHClient) Download(src io.WriteCloser, dst string) error
- func (c *MockSSHClient) GetSSHPassword() string
- func (c *MockSSHClient) GetSSHPrivateKey() string
- func (c *MockSSHClient) Run(command string, stdout io.Writer, stderr io.Writer) error
- func (c *MockSSHClient) SetSSHPassword(s string)
- func (c *MockSSHClient) SetSSHPrivateKey(s string)
- func (c *MockSSHClient) Upload(src io.Reader, dst string, mode uint32) error
- func (c *MockSSHClient) Validate() error
- func (c *MockSSHClient) WaitForSSH(maxWait time.Duration) error
- type Options
- type SSHClient
- func (client *SSHClient) Connect() error
- func (client *SSHClient) Disconnect()
- func (client *SSHClient) Download(dst io.WriteCloser, remotePath string) error
- func (client *SSHClient) GetSSHPassword() string
- func (client *SSHClient) GetSSHPrivateKey() string
- func (client *SSHClient) Run(command string, stdout io.Writer, stderr io.Writer) error
- func (client *SSHClient) SetSSHPassword(s string)
- func (client *SSHClient) SetSSHPrivateKey(s string)
- func (client *SSHClient) Upload(src io.Reader, dst string, mode uint32) error
- func (client *SSHClient) Validate() error
- func (client *SSHClient) WaitForSSH(maxWait time.Duration) error
Constants ¶
const ( // PasswordAuth represents password based auth. PasswordAuth = "password" // KeyAuth represents key based authentication. KeyAuth = "key" // Timeout for connecting to an SSH server. Timeout = 60 * time.Second )
Variables ¶
var ( // ErrInvalidUsername is returned when the username is invalid. ErrInvalidUsername = errors.New("A valid username must be supplied") // ErrInvalidAuth is returned when the username is invalid. ErrInvalidAuth = errors.New("Invalid authorization method: missing password or key") // ErrSSHInvalidMessageLength is returned when the scp implementation gets an invalid number of messages. ErrSSHInvalidMessageLength = errors.New("Invalid message length") // ErrTimeout is returned when a timeout occurs waiting for sshd to respond. ErrTimeout = errors.New("Timed out waiting for sshd to respond") // ErrKeyGeneration is returned when the library fails to generate a key. ErrKeyGeneration = errors.New("Unable to generate key") // ErrValidation is returned when we fail to validate a key. ErrValidation = errors.New("Unable to validate key") // ErrPublicKey is returned when gossh fails to parse the public key. ErrPublicKey = errors.New("Unable to convert public key") // ErrUnableToWriteFile is returned when the library fails to write to a file. ErrUnableToWriteFile = errors.New("Unable to write file") // ErrNotImplemented is returned when a function is not implemented (typically by the Mock implementation). ErrNotImplemented = errors.New("Operation not implemented") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Connect() error Disconnect() Download(src io.WriteCloser, dst string) error Run(command string, stdout io.Writer, stderr io.Writer) error Upload(src io.Reader, dst string, mode uint32) error Validate() error WaitForSSH(maxWait time.Duration) error SetSSHPrivateKey(string) GetSSHPrivateKey() string SetSSHPassword(string) GetSSHPassword() string }
Client represents an interface for abstracting common ssh operations.
type Credentials ¶
type Credentials struct { SSHUser string SSHPassword string SSHPrivateKey string // contains filtered or unexported fields }
Credentials supplies SSH credentials.
type KeyPair ¶
KeyPair represents a Public and Private keypair.
func NewKeyPair ¶
NewKeyPair generates a new SSH keypair. This will return a private & public key encoded as DER.
func (*KeyPair) Fingerprint ¶
Fingerprint calculates the fingerprint of the public key
func (*KeyPair) ReadFromFile ¶
ReadFromFile reads a keypair from files.
type MockSSHClient ¶
type MockSSHClient struct { MockConnect func() error MockDisconnect func() MockDownload func(src io.WriteCloser, dst string) error MockRun func(command string, stdout io.Writer, stderr io.Writer) error MockUpload func(src io.Reader, dst string, mode uint32) error MockValidate func() error MockWaitForSSH func(maxWait time.Duration) error MockSetSSHPrivateKey func(string) MockGetSSHPrivateKey func() string MockSetSSHPassword func(string) MockGetSSHPassword func() string }
MockSSHClient represents a Mock Client wrapper.
func (*MockSSHClient) Connect ¶
func (c *MockSSHClient) Connect() error
Connect calls the mocked connect.
func (*MockSSHClient) Disconnect ¶
func (c *MockSSHClient) Disconnect()
Disconnect calls the mocked disconnect.
func (*MockSSHClient) Download ¶
func (c *MockSSHClient) Download(src io.WriteCloser, dst string) error
Download calls the mocked download.
func (*MockSSHClient) GetSSHPassword ¶
func (c *MockSSHClient) GetSSHPassword() string
GetSSHPassword calls the mocked GetSSHPassword
func (*MockSSHClient) GetSSHPrivateKey ¶
func (c *MockSSHClient) GetSSHPrivateKey() string
GetSSHPrivateKey calls the mocked GetSSHPrivateKey
func (*MockSSHClient) SetSSHPassword ¶
func (c *MockSSHClient) SetSSHPassword(s string)
SetSSHPassword calls the mocked SetSSHPassword
func (*MockSSHClient) SetSSHPrivateKey ¶
func (c *MockSSHClient) SetSSHPrivateKey(s string)
SetSSHPrivateKey calls the mocked SetSSHPrivateKey
func (*MockSSHClient) Validate ¶
func (c *MockSSHClient) Validate() error
Validate calls the mocked validate.
func (*MockSSHClient) WaitForSSH ¶
func (c *MockSSHClient) WaitForSSH(maxWait time.Duration) error
WaitForSSH calls the mocked WaitForSSH
type SSHClient ¶
type SSHClient struct { Creds *Credentials IP net.IP Port int Options Options // contains filtered or unexported fields }
SSHClient provides details for the SSH connection.
func (*SSHClient) Disconnect ¶
func (client *SSHClient) Disconnect()
Disconnect should be called when the ssh client is no longer needed, and state can be cleaned up
func (*SSHClient) Download ¶
func (client *SSHClient) Download(dst io.WriteCloser, remotePath string) error
Download downloads a file via SSH (SCP)
func (*SSHClient) GetSSHPassword ¶
GetSSHPassword gets the SSH password on the clients credentials.
func (*SSHClient) GetSSHPrivateKey ¶
GetSSHPrivateKey gets the private key on the clients credentials.
func (*SSHClient) SetSSHPassword ¶
SetSSHPassword sets the SSH password on the clients credentials.
func (*SSHClient) SetSSHPrivateKey ¶
SetSSHPrivateKey sets the private key on the clients credentials.