Documentation ¶
Overview ¶
A runner package that executes commands on remote hosts.
Index ¶
- Constants
- 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)
- func GetSSMCommandInvocationStdErr(out ssm.GetCommandInvocationOutput) string
- func GetSSMCommandInvocationStdOut(out ssm.GetCommandInvocationOutput) string
- type AWSRunner
- func (run AWSRunner) AssociateInstanceProfileWithRunner(cfg aws.Config, instanceProfile types.InstanceProfile) (string, error)
- func (run AWSRunner) DisassociateInstanceProfileFromRunner(cfg aws.Config, associationID string) error
- func (run AWSRunner) RunSSMCommandOnRemoteHost(cfg aws.Config, operation string) (ssm.GetCommandInvocationOutput, error)
- func (run AWSRunner) SendAndUseIdentityFile(cfg aws.Config) error
- func (run AWSRunner) SendPublicKey(pubBytes []byte, cfg aws.Config) error
- type GCPRunner
- type Runner
Constants ¶
const SSMInstancePolicy string = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
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
func GetPublicKeyBytes ¶ added in v0.43.0
Takes an rsa.PublicKey and returns bytes suitable for writing to .pub file Returns in the format "ssh-rsa ..."
func GetSSMCommandInvocationStdErr ¶ added in v1.11.0
func GetSSMCommandInvocationStdErr(out ssm.GetCommandInvocationOutput) string
GetSSMCommandInvocationStdErr is a helper function to safely deference the SSM struct we receive from the AWS API.
func GetSSMCommandInvocationStdOut ¶ added in v1.11.0
func GetSSMCommandInvocationStdOut(out ssm.GetCommandInvocationOutput) string
GetSSMCommandInvocationStdOut is a helper function to safely deference the SSM struct we receive from the AWS API.
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 (AWSRunner) AssociateInstanceProfileWithRunner ¶ added in v1.6.0
func (run AWSRunner) AssociateInstanceProfileWithRunner( cfg aws.Config, instanceProfile types.InstanceProfile, ) (string, error)
AssociateInstanceProfileWithRunner associates a given instance profile with the receiving runner. First checks if there are any instance profiles already associated with the runner, and returns an error if so (since a runner can only have one instance profile associated with it). Then associates the instance profile with the runner. Returns the association ID or an error.
func (AWSRunner) DisassociateInstanceProfileFromRunner ¶ added in v1.8.0
func (AWSRunner) RunSSMCommandOnRemoteHost ¶ added in v1.6.0
func (run AWSRunner) RunSSMCommandOnRemoteHost(cfg aws.Config, operation string) ( ssm.GetCommandInvocationOutput, error, )
RunSSMCommandOnRemoteHost takes a shell command to install the agent on the runner the runner and executes it using SSM. `operation` must be one of the commands allowed by the SSM document. This function will not return until the command is in a terminal state, or until 2min have passed.
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 }