First-Time SSH Setup (macOS)
On macOS, you can configure SSH to automatically use your keys with the system keychain so you don’t have to re-enter passphrases after each restart.
1️⃣ Add Your Key to the Keychain
ssh-add --apple-use-keychain ~/.ssh/id_rsa
Replace
~/.ssh/id_rsawith the path to your private key if different.
2️⃣ Configure SSH to Always Use the Keychain
Edit (or create) ~/.ssh/config:
Host *
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
What this does:
UseKeychain yes— Store the passphrase in the macOS keychainAddKeysToAgent yes— Automatically load the key into ssh-agentIdentityFile ~/.ssh/id_rsa- Points to your specific key so SSH knows where to find it
3️⃣ Test the Connection
ssh user@your-server.com
If it connects without asking for your passphrase, the setup worked.
Tip:
You can still add host-specific settings (like HostName, User, Port, IdentityFile) in the same ~/.ssh/config if needed for staging or production environments.