Documentation
¶
Index ¶
- Constants
- func EnsureKnownHosts(bastion string) error
- func GetAuthMethods(kp KeyPair) ([]ssh.AuthMethod, error)
- func KeyScan(bastion string) (*string, error)
- func SSH(host string, kp KeyPair, sp progress.StateProvider) error
- func StartInteractiveSSHShell(sshConfig *ssh.ClientConfig, network string, host string, port string, ...) error
- func StartRemoteListener(client *ssh.Client, sp progress.StateProvider)
- type KeyPair
- type LocalStateProvider
- type PrivateKey
- type PublicKey
- type StateProvider
Constants ¶
const ConfigPath = "~/.kubesim/cp_simulator_config"
ConfigPath is the path to write the simulator SSH config file
const KnownHostsPath = "~/.kubesim/cp_simulator_known_hosts"
KnownHostsPath is the path to write the simulator SSH config file
const PrivateKeyPath = "~/.kubesim/cp_simulator_rsa"
PrivateKeyPath is the path to the key to be generated and used by simulator
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 ¶
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 ¶
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