LinuxCommandLibrary

ssh-add

TLDR

Add the default SSH keys to the agent

$ ssh-add
copy
Add a specific key to the agent
$ ssh-add [~/.ssh/id_ed25519]
copy
List fingerprints of loaded keys
$ ssh-add -l
copy
List public keys of loaded identities
$ ssh-add -L
copy
Remove a specific key from the agent
$ ssh-add -d [~/.ssh/id_rsa]
copy
Remove all keys from the agent
$ ssh-add -D
copy
Add a key with a lifetime (seconds)
$ ssh-add -t [3600] [~/.ssh/id_rsa]
copy

SYNOPSIS

ssh-add [-cDdKkLlqvXx] [-E fingerprinthash] [-S provider] [-t life] [file ..._]

DESCRIPTION

ssh-add adds private key identities to the ssh-agent authentication agent. Without arguments, it attempts to add ~/.ssh/idrsa, ~/.ssh/idecdsa, ~/.ssh/id_ed25519, and corresponding FIDO keys.
Once keys are added to the agent, SSH can authenticate without requiring the passphrase for each connection. The agent must be running and the SSHAUTHSOCK environment variable must be set.
If a key requires a passphrase, ssh-add prompts from the terminal. The SSH_ASKPASS environment variable can specify a graphical password prompt program.

PARAMETERS

-l

List fingerprints of all identities in the agent
-L
List public key parameters of all identities
-d
Remove specified identity from the agent
-D
Remove all identities from the agent
-t life
Set maximum lifetime for added keys (in seconds or sshd_config time format)
-x
Lock the agent with a password
-X
Unlock the agent
-K
Load resident keys from a FIDO authenticator
-c
Require confirmation before using the key
-v
Verbose mode for debugging

CAVEATS

Keys remain in memory while the agent runs; lock with -x on shared systems. The agent socket (SSHAUTHSOCK) must be protected from other users. Use -t to auto-expire keys for enhanced security.

HISTORY

ssh-add is part of OpenSSH, developed by the OpenBSD project. The SSH agent concept allows secure key management without repeatedly entering passphrases, originating from the SSH1 implementation in the 1990s.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community