ssh

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigPath = "~/.kubesim/cp_simulator_config"

ConfigPath is the path to write the simulator SSH config file

View Source
const KnownHostsPath = "~/.kubesim/cp_simulator_known_hosts"

KnownHostsPath is the path to write the simulator SSH config file

View Source
const PrivateKeyPath = "~/.kubesim/cp_simulator_rsa"

PrivateKeyPath is the path to the key to be generated and used by simulator

View Source
const PublicKeyPath = PrivateKeyPath + ".pub"

PublicKeyPath is the path to the key to be generated and used by simulator

Variables

This section is empty.

Functions

func EnsureKnownHosts

func EnsureKnownHosts(bastion string) error

EnsureKnownHosts scans the bastion host for its SSH keys and writes them to a custom known hosts location for promptless interaction with the infrastructure. Return an error if any occurred

func GetAuthMethods

func GetAuthMethods(kp KeyPair) ([]ssh.AuthMethod, error)

GetAuthMethods tries to contact ssh-agent to get the AuthMethods and falls back to reading the keyfile directly in case of a missing SSH_AUTH_SOCK env var or an error dialing the unix socket

func KeyScan

func KeyScan(bastion string) (*string, error)

KeyScan runs ssh-keyscan silently against the provided bastion address. It returns a pointer to a string containing its buffered stdout or an error if any occurred

func SSH

func SSH(host string, kp KeyPair, sp progress.StateProvider) error

SSH establishes an interactive Secure Shell session to the supplied host as user ubuntu and on port 22. SSH uses ssh-agent to get the key to use

func StartInteractiveSSHShell

func StartInteractiveSSHShell(sshConfig *ssh.ClientConfig, network string, host string, port string, kp KeyPair, sp progress.StateProvider) error

StartInteractiveSSHShell starts an interactive SSH shell with the supplied ClientConfig

func StartRemoteListener

func StartRemoteListener(client *ssh.Client, sp progress.StateProvider)

StartRemoteListener sets up a remote listener on the SSH connection

Types

type KeyPair

type KeyPair struct {
	PublicKey  PublicKey
	PrivateKey PrivateKey
}

KeyPair has an SSH Private and Public key pair

type LocalStateProvider

type LocalStateProvider struct{}

LocalStateProvider is the default State provider and persists all state into the local ~/.kubesim directory

func (LocalStateProvider) GetSSHConfig

func (ls LocalStateProvider) GetSSHConfig() (*string, error)

GetSSHConfig reads the config from the local ~/.ssh directory

func (LocalStateProvider) GetSSHKeyPair

func (ls LocalStateProvider) GetSSHKeyPair() (*KeyPair, error)

GetSSHKeyPair returns an existing SSH keypair or creates one locally

func (LocalStateProvider) SaveSSHConfig

func (ls LocalStateProvider) SaveSSHConfig(config string) error

SaveSSHConfig saves the config supplied to the local ~/.ssh directory

type PrivateKey

type PrivateKey string

PrivateKey represents an SSH PrivateKey

func (PrivateKey) ToAuthMethod

func (pk PrivateKey) ToAuthMethod() (ssh.AuthMethod, error)

ToAuthMethod converts the SSHPrivateKey to an AuthMethod required by the crypto ssh library

func (PrivateKey) ToBase64

func (pk PrivateKey) ToBase64() string

ToBase64 returns the base64 encoded string representation of the private key

type PublicKey

type PublicKey string

PublicKey represents an SSH PublicKey

type StateProvider

type StateProvider interface {
	GetSSHKeyPair() (*KeyPair, error)
	SaveSSHConfig(config string) error
	GetSSHConfig() (*string, error)
}

StateProvider provides methods for storing or retrieving state about a user and their cluster

Jump to

Keyboard shortcuts

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