How to permanently save SSH private key’s passphrase to OSX Keychain

Keychain is really a convenient tool for managing passwords even for terminal users, specifically for those people who uses passphrase in their private key. For newer versions of OSX, Catalina in my case, there’s an additional step to add and being able to use it.

I will be assuming that you already have your private key with you and just want to make things more convenient.

Step 1 — Add your Private Key to Keychain

ssh-add -K ~/.ssh/[name of your private key]

Enter your passphrase, then hit enter.

Step 2 — Allow SSH to use always your keychain

Modify your SSH configuration file ~/.ssh/config and add the following lines:

Host *
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/[name of your private key]

Note: If you are using multiple private keys, just add a new IdentityFile entry in your SSH config.