Documentation ¶
Index ¶
- Constants
- func Base64PrivateKey(name string) (*string, error)
- func EnsureKey() (bool, error)
- func EnsureKnownHosts(bastion string) error
- func EnsureSSHConfig(cfg string) error
- func GenerateKey(privatekeypath string) (*string, error)
- func GetAuthMethods() ([]ssh.AuthMethod, error)
- func KeyScan(bastion string) (*string, error)
- func PrivateKeyFile() (ssh.AuthMethod, error)
- func PublicKey() (*string, error)
- func SSH(host string) error
- func StartInteractiveSSHShell(sshConfig *ssh.ClientConfig, network string, host string, port string) error
Constants ¶
const PrivateKeyPath = "~/.ssh/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
const SSHConfigPath = "~/.ssh/cp_simulator_config"
SSHConfigPath is the path to write the simulator SSH config file
const SSHKnownHostsPath = "~/.ssh/cp_simulator_known_hosts"
SSHKnownHostsPath is the path to write the simulator SSH config file
Variables ¶
This section is empty.
Functions ¶
func Base64PrivateKey ¶
Base64PrivateKey returns a pointer to a string containing the base64 encoded private key or an error
func EnsureKey ¶
EnsureKey ensures there is a well-known simulator key available and returns true if it generates a new one or an error if any
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 EnsureSSHConfig ¶
EnsureSSHConfig writes the SSH config file for simulator that is needed for the `perturb.sh` scripts to run succesfully via the bastion
func GenerateKey ¶
GenerateKey runs ssh-keygen silently to create an SSH key with the same provided using preconfigured settings It returns a pointer to a string containing the buffered stdout or an error if any occurred
func GetAuthMethods ¶
func GetAuthMethods() ([]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 PrivateKeyFile ¶
func PrivateKeyFile() (ssh.AuthMethod, error)
PrivateKeyFile reads the private key at the path supplied and returns the ssh.AuthMethod to use or an error if any occurred
func PublicKey ¶
PublicKey reads the public key and return a pointer to a string with its contents or any error
func SSH ¶
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) error
StartInteractiveSSHShell starts an interactive SSH shell with the supplied ClientConfig
Types ¶
This section is empty.