pkg

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAWSConfig

func BuildAWSConfig(ctx context.Context, service string) (aws.Config, error)

func GenerateEphemeralSSHKey added in v0.7.0

func GenerateEphemeralSSHKey() (signer ssh.Signer, pubKeyAuthorizedFormat string, err error)

GenerateEphemeralSSHKey creates a throwaway Ed25519 key pair in memory. The returned signer is used directly for SSH authentication; the public key string (authorized_keys format) is what gets pushed via EC2 Instance Connect.

func GetEC2Password added in v0.7.0

func GetEC2Password(ctx context.Context, cfg aws.Config, instanceID, privateKeyPath string) (string, error)

GetEC2Password retrieves and decrypts the administrator password for a Windows EC2 instance. The privateKeyPath must be the path to the RSA private key (.pem) associated with the instance's key pair.

func HasVersionFlag added in v0.7.0

func HasVersionFlag(args []string) bool

HasVersionFlag checks if any of the arguments is -V (version query).

func InitializeClient added in v0.3.0

func InitializeClient()

func IsSSHCompatMode added in v0.7.0

func IsSSHCompatMode(args []string) bool

IsSSHCompatMode checks if the given os.Args indicate OpenSSH-compatible mode. This is true when the first argument after the program name starts with "-" (not a cobra subcommand) or when the binary is invoked via a symlink named "ssh".

func ParseHostPort added in v0.7.0

func ParseHostPort(target string, defaultUser string, defaultPort int) (user, host string, port int, err error)

ParseHostPort parses a target string in the format "[user@]host[:port]" and returns the user, host, and port components. If no user is specified, defaultUser is used. If no port is specified, defaultPort is used.

func ProxyHttpClient

func ProxyHttpClient() *awshttp.BuildableClient

BuildAWSConfig builds the AWS Config for the given service

func RunSSHCompat added in v0.7.0

func RunSSHCompat(osArgs []string) error

RunSSHCompat is the entry point for OpenSSH-compatible mode. It parses OpenSSH-style arguments, reads SSH config, merges settings, and establishes an SSH-over-SSM session.

func SendInstanceConnectKey added in v0.7.0

func SendInstanceConnectKey(ctx context.Context, cfg aws.Config, instanceID, user, pubKeyContent string) error

SendInstanceConnectKey pushes a temporary SSH public key to an EC2 instance via EC2 Instance Connect. The key is valid for 60 seconds, which is enough time to establish a connection.

func StartEC2InstanceConnect

func StartEC2InstanceConnect(target string) error

StartEC2InstanceConnect starts a SSH session using EC2 Instance Connect.

func StartSSHDirectSession added in v0.7.0

func StartSSHDirectSession(target string) error

StartSSHDirectSession starts a direct SSH session to the target EC2 instance via AWS SSM without requiring an external SSH client.

func StartSSHSession

func StartSSHSession(target string) error

StartSSHSession starts a SSH session using AWS SSM.

func StartSSMPortForwarder

func StartSSMPortForwarder(target string, sourcePort int) error

StartSSMPortForwarder starts a port forwarding session using AWS SSM.

func StartSSMShell

func StartSSMShell(target string) error

StartSSMShell starts a shell session using AWS SSM

Types

type BrowserOpenError added in v0.4.0

type BrowserOpenError struct {
	Err error
}

BrowserOpenError Failed to open a browser

func (BrowserOpenError) Error added in v0.4.0

func (e BrowserOpenError) Error() string

func (BrowserOpenError) Unwrap added in v0.4.0

func (e BrowserOpenError) Unwrap() error

type CacheFileCreationError added in v0.4.0

type CacheFileCreationError struct {
	Err           error
	Reason        string
	CacheFilePath string
}

func (CacheFileCreationError) Error added in v0.4.0

func (e CacheFileCreationError) Error() string

func (CacheFileCreationError) Unwrap added in v0.4.0

func (e CacheFileCreationError) Unwrap() error

type CacheFilepathGenerationError added in v0.4.0

type CacheFilepathGenerationError struct {
	ProfileName        string
	ProfileSSOStartURL string
	Err                error
}

CacheFilepathGenerationError failed to generate a valid filepath for the given SSO start URL

func NewCacheFilepathGenerationError added in v0.4.0

func NewCacheFilepathGenerationError(ProfileName string, ProfileSSOStartURL string, err error) CacheFilepathGenerationError

func (CacheFilepathGenerationError) Error added in v0.4.0

func (CacheFilepathGenerationError) Unwrap added in v0.4.0

type ConfigFileLoadError added in v0.4.0

type ConfigFileLoadError struct {
	Err error
}

ConfigFileLoadError failed to load default config

func (ConfigFileLoadError) Error added in v0.4.0

func (e ConfigFileLoadError) Error() string

func (ConfigFileLoadError) Unwrap added in v0.4.0

func (e ConfigFileLoadError) Unwrap() error

type CredCacheError added in v0.4.0

type CredCacheError struct {
	Err error
}

CredCacheError failed to retrieve creds from ssoCredsProvider

func (CredCacheError) Error added in v0.4.0

func (e CredCacheError) Error() string

func (CredCacheError) Unwrap added in v0.4.0

func (e CredCacheError) Unwrap() error

type GetCallerIdError added in v0.4.0

type GetCallerIdError struct {
	Err error
}

GetCallerIdError stsClient.GetCallerIdentity failed

func (GetCallerIdError) Error added in v0.4.0

func (e GetCallerIdError) Error() string

func (GetCallerIdError) Unwrap added in v0.4.0

func (e GetCallerIdError) Unwrap() error

type IdentityResult added in v0.4.0

type IdentityResult struct {
	Identity *sts.GetCallerIdentityOutput
	Error    error
}

IdentityResult contains the result of stsClient.GetCallerIdentity. If Identity is nul and error is not nul that can indicate that the credentials might be invalid.

type LoadingConfigFileError added in v0.4.0

type LoadingConfigFileError struct {
	ConfigFilePath string
	Err            error
}

LoadingConfigFileError failed to load the config file

func NewLoadingConfigFileError added in v0.4.0

func NewLoadingConfigFileError(configFilePath string, err error) LoadingConfigFileError

func (LoadingConfigFileError) Error added in v0.4.0

func (e LoadingConfigFileError) Error() string

func (LoadingConfigFileError) Unwrap added in v0.4.0

func (e LoadingConfigFileError) Unwrap() error

type MissingProfileError added in v0.4.0

type MissingProfileError struct {
	ProfileName    string
	ConfigFilePath string
	Err            error
}

MissingProfileError failed to find the requested profile

func NewMissingProfileError added in v0.4.0

func NewMissingProfileError(profileName string, configFilePath string, err error) MissingProfileError

func (MissingProfileError) Error added in v0.4.0

func (e MissingProfileError) Error() string

func (MissingProfileError) Unwrap added in v0.4.0

func (e MissingProfileError) Unwrap() error

type OsUserError added in v0.4.0

type OsUserError struct {
	Err error
}

OsUserError failed to retrieve user from osUser

func (OsUserError) Error added in v0.4.0

func (e OsUserError) Error() string

func (OsUserError) Unwrap added in v0.4.0

func (e OsUserError) Unwrap() error

type ProfileValidationError added in v0.4.0

type ProfileValidationError struct {
	ProfileName    string
	ConfigFilePath string
	FieldName      string
	CurrentValue   string
	ExpectedValue  string
}

ProfileValidationError error validating the given AWS profile. A required value may be missing.

func NewProfileValidationError added in v0.4.0

func NewProfileValidationError(profileName string, configFilePath string, fieldName string, currentValue string, expectedValue string) ProfileValidationError

func (ProfileValidationError) Error added in v0.4.0

func (e ProfileValidationError) Error() string

type SSHArgs added in v0.7.0

type SSHArgs struct {
	User           string            // -l flag or user@ prefix
	Host           string            // positional destination (after extracting user@)
	Port           int               // -p flag (default 22)
	IdentityFile   string            // -i flag
	ConfigFile     string            // -F flag
	DisablePTY     bool              // -T flag
	Options        map[string]string // -o key=value pairs
	Command        string            // trailing command after destination (joined)
	Verbose        int               // -v count (1, 2, or 3)
	NoCommand      bool              // -N flag
	DynamicForward string            // -D flag (ignored, stored for compat)
	ForwardAgent   bool              // -A flag
	ExitOnForward  bool              // -f flag (background, ignored)
	ForcePTY       bool              // -t flag
	Subsystem      bool              // -s flag
}

SSHArgs holds the parsed OpenSSH-compatible command-line arguments.

func ParseSSHArgs added in v0.7.0

func ParseSSHArgs(args []string) (*SSHArgs, error)

ParseSSHArgs parses OpenSSH-compatible command-line arguments. It handles the subset of flags that VSCode Remote SSH uses.

func (*SSHArgs) GetOption added in v0.7.0

func (a *SSHArgs) GetOption(key string) (string, bool)

GetOption returns the value of an SSH option (case-insensitive key match).

type SSHHostConfig added in v0.7.0

type SSHHostConfig struct {
	HostName            string
	User                string
	Port                string
	IdentityFile        string
	StrictHostKeyCheck  string
	UserKnownHostsFile  string
	ConnectTimeout      string
	ServerAliveInterval string
	ServerAliveCountMax string
}

SSHHostConfig holds the resolved configuration for a single SSH host.

func ParseSSHConfig added in v0.7.0

func ParseSSHConfig(configFile, host string) *SSHHostConfig

ParseSSHConfig reads an SSH config file and returns the resolved settings for the given host. It processes Host directives and applies matching blocks in order (first match wins for each directive, per OpenSSH semantics).

type SSOLoginInput added in v0.4.0

type SSOLoginInput struct {
	// ProfileName name of the profile in ~/.aws/config. [profile <ProfileName>]
	ProfileName string

	// LoginTimeout max time to wait for user to complete the SSO OIDC URL flow. This should be > 60 seconds. Default value is 90 seconds
	LoginTimeout time.Duration

	// Headed if true a browser will be opened with the URL for the SSO OIDC flow. You will have the [LoginTimeout] to
	// complete the flow in the browser.
	Headed bool

	// ForceLogin if true forces a new SSO OIDC flow even if the cached creds are still valid.
	ForceLogin bool
}

type SSOLoginOutput added in v0.4.0

type SSOLoginOutput struct {
	Credentials      *aws.Credentials
	CredentialsCache *aws.CredentialsCache
	IdentityResult   *IdentityResult
}

func SSOLogin added in v0.4.0

func SSOLogin(ctx context.Context, params *SSOLoginInput) (*SSOLoginOutput, error)

Login runs through the AWS CLI login flow if there isn't a ~/.aws/sso/cache file with valid creds. If ForceLogin is true then the login flow will always be triggered even if the cache is valid

type SsoOidcClientError added in v0.4.0

type SsoOidcClientError struct {
	Err error
}

SsoOidcClientError Failed to register ssoOidcClient

func (SsoOidcClientError) Error added in v0.4.0

func (e SsoOidcClientError) Error() string

func (SsoOidcClientError) Unwrap added in v0.4.0

func (e SsoOidcClientError) Unwrap() error

type SsoOidcTokenCreationError added in v0.4.0

type SsoOidcTokenCreationError struct {
	Err error
}

SsoOidcTokenCreationError failed to retrieve user from osUser

func (SsoOidcTokenCreationError) Error added in v0.4.0

func (SsoOidcTokenCreationError) Unwrap added in v0.4.0

func (e SsoOidcTokenCreationError) Unwrap() error

type StartDeviceAuthorizationError added in v0.4.0

type StartDeviceAuthorizationError struct {
	Err error
}

StartDeviceAuthorizationError Failed to startDeviceAuthorization

func (StartDeviceAuthorizationError) Error added in v0.4.0

func (StartDeviceAuthorizationError) Unwrap added in v0.4.0

Jump to

Keyboard shortcuts

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