Documentation
¶
Index ¶
- Variables
- func GenerateSSHKey(path string) error
- func NewNativeConfig(user string, auth *Auth) (ssh.ClientConfig, error)
- func SetDefaultClient(clientType ClientType)
- type Auth
- type Client
- type ClientType
- type ExternalClient
- type KeyPair
- type NativeClient
- func (client *NativeClient) Output(command string) (string, error)
- func (client *NativeClient) OutputWithPty(command string) (string, error)
- func (client *NativeClient) Shell(args ...string) error
- func (client *NativeClient) Start(command string) (io.ReadCloser, io.ReadCloser, error)
- func (client *NativeClient) Wait() error
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
GenerateSSHKey generates 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 ClientType)
Types ¶
type Client ¶
type Client interface {
Output(command string) (string, error)
Shell(args ...string) error
// Start starts the specified command without waiting for it to finish. You
// have to call the Wait function for that.
//
// The first two io.ReadCloser are the standard output and the standard
// error of the executing command respectively. The returned error follows
// the same logic as in the exec.Cmd.Start function.
Start(command string) (io.ReadCloser, io.ReadCloser, error)
// Wait waits for the command started by the Start function to exit. The
// returned error follows the same logic as in the exec.Cmd.Wait function.
Wait() error
}
func NewNativeClient ¶
func NewNativeClient(user, host string, port int, auth *Auth) (Client, error)
type ClientType ¶ added in v0.5.1
type ClientType string
const (
External ClientType = "external"
Native ClientType = "native"
)
type ExternalClient ¶
type ExternalClient struct {
BaseArgs []string
BinaryPath string
// contains filtered or unexported fields
}
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)
type KeyPair ¶
type KeyPair struct {
PrivateKey []byte
PublicKey []byte
}
func NewKeyPair ¶
func NewKeyPair() (keyPair *KeyPair, err error)
NewKeyPair generates a new SSH keypair This will return a private & public key encoded as DER.
func (*KeyPair) Fingerprint ¶
func (kp *KeyPair) Fingerprint() string
Fingerprint calculates the fingerprint of the public key
func (*KeyPair) WriteToFile ¶
func (kp *KeyPair) WriteToFile(privateKeyPath string, publicKeyPath string) error
WriteToFile writes keypair to files
type NativeClient ¶
type NativeClient struct {
Config ssh.ClientConfig
Hostname string
Port int
// contains filtered or unexported fields
}
func (*NativeClient) OutputWithPty ¶
func (client *NativeClient) OutputWithPty(command string) (string, error)
Click to show internal directories.
Click to hide internal directories.