Adding all ssh keys automatically to MacOS High Sierra

Since upgrading to High Sierra, I’ve had to manually add keys after every reboot using ssh-add like this:

ssh-add -K

I don’t reboot often but for a while I was rebooting often enough to make it annoying. So I found that you can link ssh with MacOS keychain using your .ssh/config file, add all the keys to your agent, and everything works smoothly.

Host *
UseKeychain yes
AddKeysToAgent yes

Then add all your keys to the keychain using

ssh-add -KA