ssh

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPublicKeyToRemoteNode

func AddPublicKeyToRemoteNode(host string, port int32, username string, password string, publicKey []byte) error

AddPublicKeyToRemoteNode will add the publicKey to the username@host:port's authorized_keys file w/password

func GenerateSSHKeyPair

func GenerateSSHKeyPair() (private []byte, public []byte, err error)

GenerateSSHKeyPair creates a ECDSA a x509 ASN.1-DER format-PEM encoded private key string and a SHA256 encoded public key string

func SetupPrivateKeyAccess

func SetupPrivateKeyAccess(machine MachineParams, privateKey []byte, publicKey []byte) error

Types

type BatchRunner

type BatchRunner struct {
	// contains filtered or unexported fields
}

BatchRunner is used for running multiple ssh commands on a single client.

func NewBatchRunner

func NewBatchRunner(c *Client, out io.Writer) *BatchRunner

func (*BatchRunner) Err

func (b *BatchRunner) Err() error

func (*BatchRunner) Run

func (b *BatchRunner) Run(cmds ...Cmd)

Run executes all the commands on the client. If any of the commands return an error then all remaining commands will be skipped. You can check the error with BatchRunner.Err(). Stdout and Stderr from the command are interleaved and are written to the BatchRunners output.

type Client

type Client struct {
	*ssh.Client
	// contains filtered or unexported fields
}

Client contains the underlying net.Conn and an ssh.Client for the conn.

func NewClient

func NewClient(address, user string, privateKey []byte) (*Client, error)

NewClient returns a client with the underlying net.Conn and an ssh.Client. You must close the ssh.Client and the net.Conn.

func (*Client) Close

func (c *Client) Close() error

type ClusterParams

type ClusterParams struct {
	Name              string
	PrivateKey        string // These are base64 _and_ PEM encoded Eliptic
	PublicKey         string // Curve (EC) keys used in JSON and YAML.
	K8SVersion        string
	ControlPlaneNodes []MachineParams
	WorkerNodes       []MachineParams
}

ClusterParams contains parameters for the entire cluster.

type Cmd

type Cmd struct {
	Command string
	Stdin   io.Reader
	Stdout  io.Writer
	Stderr  io.Writer
}

func Command

func Command(command string) Cmd

Command is a convenience method to create Cmd.

func CommandWithInput

func CommandWithInput(command string, r io.Reader) Cmd

CommandWithInput is a convenience method to create Cmd that takes input from a supplied io.Reader.

func (Cmd) Run

func (c Cmd) Run(client *Client) error

Run executes the command on the client. It handles creating ssh sessions.

type ErrorCmd

type ErrorCmd struct {
	// contains filtered or unexported fields
}

ErrorCmd is helper to return the error msg as well as the Cmd that was run.

func (ErrorCmd) Cmd

func (e ErrorCmd) Cmd() string

Cmd returns the command that was run.

func (ErrorCmd) Error

func (e ErrorCmd) Error() string

Error implements the error interface

type MachineParams

type MachineParams struct {
	Username   string
	Host       string
	PublicHost string
	Port       int32
	Password   string
}

MachineParams contains parameters for individual machines.

Directories

Path Synopsis
Package asset provides the assets to a virtual filesystem.
Package asset provides the assets to a virtual filesystem.

Jump to

Keyboard shortcuts

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