ssh

package
v0.63.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 KnownHostsFilePath = filepath.Join(os.TempDir(), "known_hosts")
View Source
var SocketAgentSocketPath = filepath.Join(os.TempDir(), "ssh_agent.sock")

Functions

func AddHostToKnownHosts

func AddHostToKnownHosts(host string) error

AddHostToKnownHosts retrieves the host key and adds it to known_hosts.

func AddKeyToAgent

func AddKeyToAgent(privateKey []byte, keyPassphrase string) error

AddKeyToAgent adds a private key to the SSH agent running at the socket specified.

func CreateKnownHostsFile

func CreateKnownHostsFile() error

CreateKnownHostsFile ensures that the known_hosts file exists and sets the SSH_KNOWN_HOSTS environment variable.

func ExtractHostFromSSHUrl

func ExtractHostFromSSHUrl(sshUrl string) (string, error)

ExtractHostFromSSHUrl extracts the host/domain from an SSH URL.

func StartSSHAgent

func StartSSHAgent(ctx context.Context, socketPath string) error

StartSSHAgent starts an SSH agent that listens on a Unix domain socket at the specified path. If no path is provided, it defaults to SocketAgentSocketPath. The function runs until the provided context is canceled.

Types

This section is empty.

Jump to

Keyboard shortcuts

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