ssh-add
Quick Reference
Command Name:
ssh-add
Category:
networking
Platform:
Linux/Unix/Windows
Basic Usage:
Common Use Cases
- 1
SSH key management
Add SSH keys to the SSH agent for password-less authentication
- 2
Security
Ensure secure communication between systems
- 3
Scripting
Use in shell scripts to automate SSH key management
- 4
Remote administration
Administer remote systems securely
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.