Documentation ¶
Overview ¶
A runner package that executes commands on remote hosts.
Index ¶
- func AddKnownHost(host string, remote net.Addr, key ssh.PublicKey, knownFile string) (err error)
- func CheckKnownHost(host string, remote net.Addr, key ssh.PublicKey, knownFile string) (found bool, err error)
- func DefaultIdentityFilePath() (string, error)
- func DefaultKnownHosts() (ssh.HostKeyCallback, error)
- func DefaultKnownHostsPath() (string, error)
- func EncodePrivateKeyToPEM(privateKey *rsa.PrivateKey) ([]byte, error)
- func GeneratePrivateKey(bitSize int) (*rsa.PrivateKey, error)
- func GetKeyBytes() ([]byte, []byte, error)
- func GetPublicKeyBytes(key *rsa.PublicKey) ([]byte, error)
- type AWSRunner
- type GCPRunner
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddKnownHost ¶ added in v0.2.12
AddKnownHost adds a host to the provided known hosts file, if no known hosts file is provided, it will fallback to default known_hosts file
func CheckKnownHost ¶ added in v0.2.12
func CheckKnownHost(host string, remote net.Addr, key ssh.PublicKey, knownFile string) (found bool, err error)
CheckKnownHost checks if a host is in known hosts file, if no known hosts file is provided, it will fallback to default known_hosts file
func DefaultIdentityFilePath ¶ added in v0.2.12
func DefaultKnownHosts ¶ added in v0.2.12
func DefaultKnownHosts() (ssh.HostKeyCallback, error)
DefaultKnownHosts returns a host key callback from default known hosts path
func DefaultKnownHostsPath ¶ added in v0.2.12
DefaultKnownHostsPath returns default user ~/.ssh/known_hosts file
func EncodePrivateKeyToPEM ¶ added in v0.43.0
func EncodePrivateKeyToPEM(privateKey *rsa.PrivateKey) ([]byte, error)
Encodes private key from RSA struct to PEM formatted bytes
func GeneratePrivateKey ¶ added in v0.43.0
func GeneratePrivateKey(bitSize int) (*rsa.PrivateKey, error)
Helper function to generate a random private key. This key will stay in memory and does not persist across test runs.
func GetKeyBytes ¶ added in v0.43.0
Generates SSH keys in EC2-readable format Returns public key bytes, private key bytes, error
Types ¶
type AWSRunner ¶ added in v0.43.0
type AWSRunner struct { Runner Runner Region string AvailabilityZone string InstanceID string ImageName string }
func NewAWSRunner ¶ added in v0.43.0
func NewAWSRunner(amiImageId, userFromCLIArg, host, region, availabilityZone, instanceID string, callback ssh.HostKeyCallback) (*AWSRunner, error)
func (AWSRunner) SendAndUseIdentityFile ¶ added in v0.43.0
func (AWSRunner) SendPublicKey ¶ added in v0.43.0
Helper function to send a public key to a test instance. Uses EC2InstanceConnect. The AWS account used to run the tests must have EC2InstanceConnect permissions attached to its IAM role. First checks to make sure the instance is still running.
type GCPRunner ¶ added in v1.1.0
type GCPRunner struct { Runner Runner ParentUsername string ProjectID string AvailabilityZone string InstanceID string }
func NewGCPRunner ¶ added in v1.1.0
func NewGCPRunner(host, parentUsername, projectID, availabilityZone, instanceID string, callback ssh.HostKeyCallback) (*GCPRunner, error)
func (GCPRunner) SendAndUseIdentityFile ¶ added in v1.1.0
func (GCPRunner) SendPublicKey ¶ added in v1.1.0
SendPublicKey is a helper function to send a public key to a GCP account for OSLogin authentication. The account must have the "Compute OS Login" IAM role and "Service Account User" authorization for the GCE default service account. When the SSH key is sent, it will persist in the GCP account for 10min.
type Runner ¶ added in v0.2.12
type Runner struct { Hostname string Port int *ssh.ClientConfig }