Is OSX Asking For Your SSH Password? I Have a Simple Fix!

A few months ago I started noticing that after I rebooted my computer, I was suddenly being prompted for my SSH key password every time a process used the key. For some programs this was acceptable, but once you start utilizing git with git-lfs, you probably give up in frustration before you finish typing your password enough times. I found that I could manually stave off this behavior by running ssh-add, but the effect only remained until I rebooted my computer.

Recently I found a permanent fix which doesn't require mucking around with ssh-add or ssh-agent. Simply open up your SSH config file (usually found in ~/.ssh/config and add the following lines:

Host *
   AddKeysToAgent yes
   IdentityFile ~/.ssh/id_rsa
   UseKeychain yes

Once you add those lines, the old SSH behavior will be restored. You may be prompted for your password once, but at least you will not be prompted repeatedly.

My SSH config file was empty, so I didn't have to worry about placement within existing configuration parameters. If your config is not empty, I recommend placing the Host * block at the end of your config file. SSH will look for the first setting that applies in your config file. If you prefer to override this behavior for specific hosts, you will need to place them above the Host * block.