$linuxjunkies
>

ssh-add(1)

Add private key identities to the SSH authentication agent.

UbuntuDebianFedoraArch

Synopsis

ssh-add [-l] [-L] [-d] [-D] [-p] [-P passphrase] [-t life] [file ...]

Description

ssh-add adds private key identities to the SSH authentication agent (ssh-agent). When ssh-add is run without arguments, it adds keys from default locations (~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519). The agent uses these keys to authenticate SSH connections without requiring you to enter passphrases repeatedly.

Keys are stored in memory for the duration of your session. You can set a lifetime for keys so they're automatically removed after a specified time period, improving security when leaving your workstation unattended.

Common options

FlagWhat it does
-lList fingerprints of all identities currently loaded in the agent
-LList public keys of all identities in OpenSSH format
-dRemove an identity from the agent (specify key file)
-DDelete all identities from the agent
-t lifeSet lifetime in seconds before key is automatically removed
-pRead passphrase from stdin instead of terminal prompt
-P passphraseUse the given passphrase to unlock the key (security risk)
-e pkcs11providerLoad keys from a PKCS#11 provider
-cRequire user confirmation for each key usage via ssh-askpass

Examples

Add default keys (~/.ssh/id_*) to the agent, prompting for passphrases

ssh-add

Add a specific private key file to the agent

ssh-add ~/.ssh/custom_key

List all loaded key fingerprints to verify which keys are available

ssh-add -l

Add a key that will be automatically removed after 1 hour (3600 seconds)

ssh-add -t 3600 ~/.ssh/id_ed25519

Remove a specific key from the agent

ssh-add -d ~/.ssh/old_key

Clear all identities from the agent (useful before leaving your desk)

ssh-add -D

List public keys and filter for Ed25519 keys

ssh-add -L | grep 'ssh-ed25519'

Add a key with confirmation required on each use

ssh-add -c ~/.ssh/id_rsa

Related commands