ssh-add
Quick Reference
Command Name:
ssh-add
Category:
networking
Platform:
Linux/Unix/Windows
Basic Usage:
Common Use Cases
- 1
Key caching
Load private keys into the SSH agent to avoid typing passphrases repeatedly
- 2
Identity management
Add, remove, and list keys managed by the SSH authentication agent
- 3
Agent security
Lock and unlock the SSH agent or add keys with time limits for better security
- 4
Hardware key integration
Work with FIDO/U2F keys and smartcards for enhanced security
Syntax
ssh-add [options] [file ...]
Options
Option | Description |
---|---|
-c | Confirm each use of the key (requires user confirmation) |
-D | Delete all identities from the agent |
-d | Remove the specified key from the agent |
-e pkcs11.so | Remove keys provided by the PKCS#11 shared library |
-k | Load resident keys from a FIDO authenticator |
-K | Load resident keys from a FIDO authenticator and keys listed in ~/.ssh/known_hosts |
-l | List fingerprints of all identities currently represented by the agent |
-L | List public key parameters of all identities currently represented by the agent |
-s pkcs11.so | Add keys provided by the PKCS#11 shared library |
-t seconds | Set a maximum lifetime when adding identities to an agent |
-v | Verbose mode, useful for debugging |
-X | Unlock the agent |
-x | Lock the agent with a password |
Examples
How to Use These Examples
The examples below show common ways to use the ssh-add
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Usage:
ssh-add
Add default SSH keys (~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519) to the agent.
ssh-add ~/.ssh/custom_key
Add a specific private key to the SSH agent.
ssh-add -l
List fingerprints of all identities currently represented by the agent.
ssh-add -L
List public key parameters of all identities currently represented by the agent.
Key Management:
ssh-add -d ~/.ssh/id_rsa
Remove a specific key from the agent.
ssh-add -D
Delete all identities from the agent.