Version: v0.5.0 Latest Latest

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

Go to latest
Published: Nov 3, 2015 License: Apache-2.0 Imports: 18 Imported by: 2,007




This section is empty.


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")


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

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

func SetDefaultClient

func SetDefaultClient(clientType SSHClientType)


type Auth

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

type Client

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

func NewClient

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

func NewNativeClient

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

type ExternalClient

type ExternalClient struct {
	BaseArgs   []string
	BinaryPath string

func NewExternalClient

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

func (ExternalClient) Output

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

func (ExternalClient) Shell

func (client ExternalClient) Shell(args ...string) error

type KeyPair

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

func NewKeyPair

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

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

func (*KeyPair) Fingerprint

func (kp *KeyPair) Fingerprint() string

Calculate the fingerprint of the public key

func (*KeyPair) WriteToFile

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

Write keypair to files

type NativeClient

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

func (NativeClient) Output

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

func (NativeClient) OutputWithPty

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

func (NativeClient) Shell

func (client NativeClient) Shell(args ...string) error

type SSHClientType

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

Source Files

Jump to

Keyboard shortcuts

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