SSH Add Command Guide
The ssh-add command is an essential utility for managing your SSH private keys. It allows you to add your private keys to the SSH authentication agent, which then holds your decrypted private keys in memory, so you don't have to enter your passphrase every time you connect to a remote server. This guide provides common usage examples for ssh-add.
Add SSH Private Key
To add a private key to the SSH agent, use the following command, replacing <keyfile> with the path to your private key file:
ssh-add <keyfile>
Load Resident Keys
For loading resident keys from a FIDO2 authenticator, use the -K option. This is particularly useful for hardware security keys.
ssh-add -K
Store SSH Passphrase
You can store your SSH passphrase in your keychain for convenience, for example, when using GitHub. This command adds the specified key and stores its passphrase.
ssh-add -K ~/.ssh/github_rsa
List Public Keys
To view a list of all public keys currently loaded by the SSH agent, use the -L option.
ssh-add -L
List Key Fingerprints
To display the fingerprints of all keys managed by the SSH agent, use the -l option. This is helpful for verifying which keys are loaded.
ssh-add -l
Delete Specific Key
If you need to remove a specific private key from the SSH agent, use the -d option followed by the key file path.
ssh-add -d <keyfile>
Delete All Keys
To remove all keys currently loaded by the SSH agent, use the -D option. This is a useful command for clearing the agent's memory.
ssh-add -D