ssh

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2015 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyGeneration     = errors.New("Unable to generate key")
	ErrValidation        = errors.New("Unable to validate key")
	ErrPublicKey         = errors.New("Unable to convert public key")
	ErrUnableToWriteFile = errors.New("Unable to write file")
)

Functions

func GenerateSSHKey

func GenerateSSHKey(path string) error

Generate SSH keypair based on path of the private key The public key would be generated to the same path with ".pub" added

func NewNativeConfig added in v0.3.0

func NewNativeConfig(user string, auth *Auth) (ssh.ClientConfig, error)

func SetDefaultClient added in v0.3.0

func SetDefaultClient(clientType SSHClientType)

func WaitForTCP

func WaitForTCP(addr string) error

Types

type Auth added in v0.3.0

type Auth struct {
	Passwords []string
	Keys      []string
}

type Client added in v0.3.0

type Client interface {
	Output(command string) (string, error)
	Shell() error
}

func NewClient added in v0.3.0

func NewClient(user string, host string, port int, auth *Auth) (Client, error)

func NewNativeClient added in v0.3.0

func NewNativeClient(user, host string, port int, auth *Auth) (Client, error)

type ExternalClient added in v0.3.0

type ExternalClient struct {
	BaseArgs   []string
	BinaryPath string
}

func NewExternalClient added in v0.3.0

func NewExternalClient(sshBinaryPath, user, host string, port int, auth *Auth) (ExternalClient, error)

func (ExternalClient) Output added in v0.3.0

func (client ExternalClient) Output(command string) (string, error)

func (ExternalClient) Shell added in v0.3.0

func (client ExternalClient) Shell() error

type KeyPair added in v0.3.0

type KeyPair struct {
	PrivateKey []byte
	PublicKey  []byte
}

func NewKeyPair added in v0.3.0

func NewKeyPair() (keyPair *KeyPair, err error)

Generate a new SSH keypair This will return a private & public key encoded as DER.

func (*KeyPair) Fingerprint added in v0.3.0

func (kp *KeyPair) Fingerprint() string

Calculate the fingerprint of the public key

func (*KeyPair) WriteToFile added in v0.3.0

func (kp *KeyPair) WriteToFile(privateKeyPath string, publicKeyPath string) error

Write keypair to files

type NativeClient added in v0.3.0

type NativeClient struct {
	Config   ssh.ClientConfig
	Hostname string
	Port     int
}

func (NativeClient) Output added in v0.3.0

func (client NativeClient) Output(command string) (string, error)

func (NativeClient) OutputWithPty added in v0.3.0

func (client NativeClient) OutputWithPty(command string) (string, error)

func (NativeClient) Shell added in v0.3.0

func (client NativeClient) Shell() error

type SSHClientType added in v0.3.0

type SSHClientType string
const (
	External SSHClientType = "external"
	Native   SSHClientType = "native"
)

Jump to

Keyboard shortcuts

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