sshclient

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvKnownHostsPath        = "SSH_KNOWN_HOSTS"
	EnvSkipHostKeyValidation = "SKIP_HOST_KEY_CHECK"
)

Variables

This section is empty.

Functions

func Configure added in v1.4.0

func Configure(opts Options) error

Configure applies SSH client options.

func DefaultKnownHostsPath added in v1.4.0

func DefaultKnownHostsPath() (string, error)

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.

Types

type ConnConfig

type ConnConfig struct {
	Host     string
	Port     int
	Username string
}

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 Options added in v1.4.0

type Options struct {
	KnownHostsPath           string
	InsecureSkipHostKeyCheck bool
}

Options controls SSH host key handling.

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.

Jump to

Keyboard shortcuts

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