Automating ssh key passphrases on MacOS

As a reminder, here’s how to use ssh keys to access remote hosts:

Adding hosts to a ~/.ssh/config file to use different keys with different git hosts is something I find I only need to do once in a while, but I made a note here because I can never remember how this is configured:

#Edit ~/.ssh/config and for each repo add the following block:
host hostname-of-repo
user your-id-for-this-repo
identityfile ~/.ssh/filename-of-key
view raw gistfile1.txt hosted with ❤ by GitHub

If you are required to use passphrases with ssh keys, being prompted to enter your passphrase every time you use a key can get tiresome. On MacOS however you can automate using your passphrase with by adding:

UseKeychain yes

to your ~/.ssh/config file (suggestion from this post here).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.