Jump to content

ssh-add

From RaySoft

ssh-add adds private key identities to the authentication agent, ssh-agent. When run without arguments, it adds the files ~/.ssh/id_rsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ecdsa_sk, ~/.ssh/id_ed25519 and ~/.ssh/id_ed25519_sk. After loading a private key, ssh-add will try to load corresponding certificate information from the filename obtained by appending -cert.pub to the name of the private key file. Alternative file names can be given on the command line.[1]

Documentation

Syntax

ssh-add [PARAMETER ...] [FILE ...]

Parameters

-d
Instead of adding identities, removes identities from the agent.
-D
Deletes all identities from the agent.
-l
Lists fingerprints of all identities currently represented by the agent.
-L
Lists public key parameters of all identities currently represented by the agent.
-q
Be quiet after a successful operation.
-t LIFETIME
Set a maximum LIFETIME when adding identities to an agent.
-x
Lock the agent with a password.
-X
Unlock the agent.

Examples

Provide git with a SSH private key
eval "$(ssh-agent -s)"

ssh-add -q "${HOME}/.ssh/id_ed25519_alex@codeberg"

git push --set-upstream 'origin' 'main'

References

  1. Project contributors. "ssh-add(1)." OpenSSH project. https://man.openbsd.org/ssh-add (accessed 18.03.2025)