If Entering Your SSH Password on macOS Is Annoying, Use macOS Keychain - ssh-add --apple-use-keychain
On macOS, integrating ssh-agent with macOS Keychain is the cleanest solution.
With ssh-agent, you can avoid entering your passphrase every time. If you do it manually, it looks like this:
# Start the agent (it is often already running)
eval "$(ssh-agent -s)"
# Add your key (you enter the passphrase once here)
ssh-add ~/.ssh/id_ed25519
However, this still becomes a hassle because you need to repeat steps in several situations:
- It stops when your shell session ends.
- You need to run it again every time you close the terminal, and the same applies after a reboot.
ssh-add --apple-use-keychain ~/.ssh/id_ed25519Warning: The old
ssh-add -Koption is deprecated. Use--apple-use-keychaininstead.
Host *
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_ed25519
That's it. Your key is automatically restored to ssh-agent when macOS starts, so once registered, no more repeated passphrase input is needed.
Keychain is part of macOS security infrastructure and integrates with Touch ID and Secure Enclave. It does not store your passphrase as plain text, so you can maintain strong security while keeping day-to-day usability.