Permanently add my ssh key to the keychain in OSX MojaveI have been using ssh keys for all my ssh authentication for years, but for some reason after upgrading to OSX Mojave I found that my key based authentication would no longer work. So I used the following command to add my ssh key to the keychain and things were working well, or so I thought.


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


This command did fix the issue, and I was able to perform ssh key based authentication again just fine… until I rebooted my mac. Fortunately my mac didn’t need to be rebooted very frequently, but then each time I would end up rebooting I would face the same conundrum… “Why am I not able to authenticate with my servers… oh right my key isn’t loaded…”. I needed to find a way to permanently add my ssh key to the keychain in OSX Mojave.

It turns out that this is a relatively simple procedure, once you know what to do. In the




file you can add specific host entries to allow you to use specific settings, ciphers, keys, etc with a certain host. Or general settings to be used for all hosts. So I just added the following line to the “Host *” section of the file


IdentityFile ~/.ssh/id_rsa


And voilĂ  they key is used each time you open an ssh connection, for any host.