Documentation
¶
Index ¶
- Constants
- func Configure(opts Options) error
- func DefaultKnownHostsPath() (string, error)
- func RunCommand(cfg ConnConfig, cmd string) (string, error)
- func RunCommands(cfg ConnConfig, commands []string) (string, error)
- type ConnConfig
- type HostKeyInfo
- type HostKeyValidationError
- type Options
- type TrustHostKeyResult
Constants ¶
const ( EnvKnownHostsPath = "SSH_KNOWN_HOSTS" EnvSkipHostKeyValidation = "SKIP_HOST_KEY_CHECK" )
Variables ¶
This section is empty.
Functions ¶
func DefaultKnownHostsPath ¶ added in v1.4.0
DefaultKnownHostsPath returns the default OpenSSH known_hosts path for the current user.
func RunCommand ¶
func RunCommand(cfg ConnConfig, cmd string) (string, error)
RunCommand dials the SSH host, executes cmd, and returns stdout. A new connection is created for each call.
func RunCommands ¶ added in v1.6.0
func RunCommands(cfg ConnConfig, commands []string) (string, error)
RunCommands dials the SSH host, executes multiple newline-delimited commands in a single non-PTY exec session, and returns stdout.
Types ¶
type ConnConfig ¶
ConnConfig holds SSH connection parameters.
type HostKeyInfo ¶ added in v1.4.0
type HostKeyInfo struct {
Host string
Port int
Address string
KnownHostsPath string
KeyType string
FingerprintSHA256 string
KnownHostsLine string
// contains filtered or unexported fields
}
HostKeyInfo describes the host key currently presented by an SSH server.
func InspectHostKey ¶ added in v1.4.0
func InspectHostKey(host string, port int) (HostKeyInfo, error)
InspectHostKey fetches the host key presented by a remote SSH server without trusting it.
type HostKeyValidationError ¶ added in v1.4.0
type HostKeyValidationError struct {
Address string
KnownHostsPath string
PresentedKeyType string
PresentedSHA256 string
MatchingKnownHosts []knownhosts.KnownKey
}
HostKeyValidationError describes an unknown or mismatched SSH host key.
func (*HostKeyValidationError) Error ¶ added in v1.4.0
func (e *HostKeyValidationError) Error() string
type TrustHostKeyResult ¶ added in v1.4.0
type TrustHostKeyResult struct {
HostKeyInfo
Action string
}
TrustHostKeyResult describes the outcome of adding or replacing a host key.
func TrustHostKey ¶ added in v1.4.0
func TrustHostKey(host string, port int, replace bool) (TrustHostKeyResult, error)
TrustHostKey adds or replaces the SSH host key in the configured known_hosts file.