sshadd

package
v0.0.0-...-ef38420 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package sshadd provides the ssh-add utility — manage SSH agent keys.

It exposes a Config struct with a Parse method for command-line argument parsing, individual action functions (Add, List, ListPublicKeys, Delete, DeleteAll, Lock, Unlock), and a Run dispatcher that connects to the agent and executes the requested action.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(cfg *Config, client agent.ExtendedAgent, streams stdio.TerminalStreams) int

Add adds private keys to the agent. If cfg.Files is empty, default key files are tried.

func ConnectAgent

func ConnectAgent() (net.Conn, error)

ConnectAgent dials the SSH agent socket specified by SSH_AUTH_SOCK.

func DefaultKeyFiles

func DefaultKeyFiles() []string

DefaultKeyFiles returns the paths of standard SSH private key files that exist in the user's ~/.ssh directory.

func Delete

func Delete(cfg *Config, client agent.ExtendedAgent, streams stdio.Streams) int

Delete removes specified keys from the agent. If cfg.Files is empty, default key files are tried.

func DeleteAll

func DeleteAll(client agent.ExtendedAgent, streams stdio.Streams) int

DeleteAll removes all keys from the agent.

func KeySize

func KeySize(key ssh.PublicKey) int

KeySize returns the key size in bits for the given public key.

func KeyTypeName

func KeyTypeName(format string) string

KeyTypeName returns a human-readable name for the SSH key type.

func List

func List(client agent.ExtendedAgent, streams stdio.Streams) int

List lists keys in the agent with fingerprints.

func ListPublicKeys

func ListPublicKeys(client agent.ExtendedAgent, streams stdio.Streams) int

ListPublicKeys lists keys in the agent in authorized_keys format.

func Lock

func Lock(client agent.ExtendedAgent, streams stdio.TerminalStreams) int

Lock locks the agent with a passphrase read from the terminal.

func Run

func Run(cfg *Config, streams stdio.TerminalStreams) int

Run connects to the SSH agent and dispatches to the appropriate action based on cfg. Returns a process exit code.

func Unlock

func Unlock(client agent.ExtendedAgent, streams stdio.TerminalStreams) int

Unlock unlocks the agent with a passphrase read from the terminal.

Types

type Config

type Config struct {
	List      bool   // -l
	ListPub   bool   // -L
	Delete    bool   // -d
	DeleteAll bool   // -D
	Lock      bool   // -x
	Unlock    bool   // -X
	Confirm   bool   // -c
	Lifetime  uint32 // -t
	Files     []string
	Version   bool // -V
}

Config holds parsed ssh-add command-line arguments.

func (*Config) Parse

func (cfg *Config) Parse(args ...string) error

Parse populates cfg from command-line arguments. Fields set before calling Parse are preserved unless overridden.

Jump to

Keyboard shortcuts

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