ssh-add(1)
Add private key identities to the SSH authentication agent.
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
| Flag | What it does |
|---|---|
-l | List fingerprints of all identities currently loaded in the agent |
-L | List public keys of all identities in OpenSSH format |
-d | Remove an identity from the agent (specify key file) |
-D | Delete all identities from the agent |
-t life | Set lifetime in seconds before key is automatically removed |
-p | Read passphrase from stdin instead of terminal prompt |
-P passphrase | Use the given passphrase to unlock the key (security risk) |
-e pkcs11provider | Load keys from a PKCS#11 provider |
-c | Require user confirmation for each key usage via ssh-askpass |
Examples
Add default keys (~/.ssh/id_*) to the agent, prompting for passphrases
ssh-addAdd a specific private key file to the agent
ssh-add ~/.ssh/custom_keyList all loaded key fingerprints to verify which keys are available
ssh-add -lAdd a key that will be automatically removed after 1 hour (3600 seconds)
ssh-add -t 3600 ~/.ssh/id_ed25519Remove a specific key from the agent
ssh-add -d ~/.ssh/old_keyClear all identities from the agent (useful before leaving your desk)
ssh-add -DList 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