ssh-add Load a key into the agent and save it in the Keychain

Gives your key to ssh-agent, the background helper macOS runs for you, so ssh can use it without asking for the passphrase each time. With the Keychain option, the passphrase is also stored in macOS so the key reloads itself after a restart.

Synopsis

ssh-add [OPTION]... [FILE]...

Common options

Option or formWhat it does
--apple-use-keychainSave the passphrase in the macOS Keychain as well as loading the key. This is the macOS spelling; older guides use -K
-lList the keys the agent currently holds
-LList the public keys of the loaded keys in full
-d FILERemove one key from the agent
-DRemove every key from the agent
-t SECONDSForget the key from the agent after this many seconds

Examples

Load your key and store the passphrase in the Keychain
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
Enter passphrase for /Users/you/.ssh/id_ed25519:
Identity added: /Users/you/.ssh/id_ed25519 (bob@google.com)
See which keys are loaded
ssh-add -l
256 SHA256:Vq0n...x9Ac bob@google.com (ED25519)
Load a key for one hour only
ssh-add -t 3600 ~/.ssh/id_ed25519_nas
Unload every key
ssh-add -D

Notes

See also

Last reviewed 2026-10-12.