ssh

package
v0.113.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KnownHostsEnvVar  = "SSH_KNOWN_HOSTS"
	DefaultGitSSHUser = "git" // Default SSH user for Git servers
	DefaultGitSSHPort = 22    // Default SSH port for Git servers
)
View Source
const (
	SocketAgentSocketEnvVar = "SSH_AUTH_SOCK"
)

Variables

View Source
var (
	ErrSSHAgentSocketPathEmpty = errors.New("socket path cannot be empty")
	ErrNoUsableSSHKeys         = errors.New("no usable SSH keys could be added to the agent")
)
View Source
var (
	KnownHostsFilePath = filepath.Join(os.TempDir(), "known_hosts")
)

Functions

func AddToKnownHosts added in v0.67.1

func AddToKnownHosts(url string) error

AddToKnownHosts adds the host from the SSH URL to the known_hosts file.

func IsHostKeyMismatchError added in v0.78.0

func IsHostKeyMismatchError(err error) bool

IsHostKeyMismatchError returns true when an SSH operation failed due to host key mismatch.

func RefreshKnownHost added in v0.78.0

func RefreshKnownHost(url string) error

RefreshKnownHost replaces the known_hosts entry for the given SSH URL and fetches the current server key.

func RegisterSSHAgent added in v0.84.0

func RegisterSSHAgent(ctx context.Context, log *slog.Logger, keys []KeyRecord) bool

RegisterSSHAgent registers an SSH agent serving the given keys, ignoring empty and duplicate entries. It reports whether an agent was registered.

Types

type KeyRecord added in v0.108.0

type KeyRecord struct {
	PrivateKey string
	Passphrase string
}

KeyRecord contains an SSH private key and its optional passphrase.

Jump to

Keyboard shortcuts

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