ssh

package
v0.0.0-...-84310d3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ask

func Ask(prompt string) string

Ask something with prompt

func AskPassword

func AskPassword(prompt string) string

AskPassword asks password using the terminal

Types

type Client

type Client struct {
	SSH *ssh.Client
}

Client wraps SSH client

func Dial

func Dial(dest Host) (*Client, error)

Dial to the host and return an ssh client

func (*Client) Close

func (c *Client) Close()

Close a client

type Host

type Host interface {
	GetID() string
	// Returns the network, "tcp"
	GetNetwork() string
	// Returns name:port
	GetHostAndPort() string
	// Returns ssh login username
	GetUserName() string

	// Return auth methods for the hots
	GetAuth() ([]ssh.AuthMethod, error)

	// Reach host via another one
	Via() Host
}

Host interface used by the ssh dialer.

type RawPrivateKey

type RawPrivateKey struct {
	sync.RWMutex
	Name       string
	File       string
	PEMData    []byte
	Passphrase string
	// contains filtered or unexported fields
}

RawPrivateKey contains the data for a private key. It can be from a file, or direct from the data

func (*RawPrivateKey) GetPrivateKey

func (x *RawPrivateKey) GetPrivateKey() (interface{}, error)

GetPrivateKey reads the key from a file, asks passphrase if necessary, and returns a private key. Once the private key is retrieved, the same instance is returned, so keep references to this instance, don't copy

func (*RawPrivateKey) GetSigner

func (x *RawPrivateKey) GetSigner() (ssh.Signer, error)

GetSigner returns a signer from the private key

Jump to

Keyboard shortcuts

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