Permanently add ssh passphrase to keychain

08 May 2017

Store passphrases in your keychain

On MacOS (and OS X) there is a handy option for ssh-add to store your key's passphrase in your keychain. ​

ssh-add -K ~/.ssh/name-of-your-key-here

​ You will be prompted to enter your passphrase after which it will be stored in keychain. ​

Load passphrase from keychain on MacOS by default

​ In MacOS (Sierra) your ssh key's passphrase is no longer automatically retrieved from keychain across sessions. ​ This means that you will be reprompted for the passphrase if you restart. Being required to re-enter your passphrase each time could be the behaviour you want for added safety, but if not we have a solution. ​ Add the following to your ~/.ssh/config file. ​

Host *
  UseKeychain yes

​ This was originally answered in a StackExchange post but I've replicated it here for my own easy access.

Share this article
Was this post helpful?
Buy me a coffeeBuy me a coffee