As part of a recent update to macOS Sierra (formally OSX), git users have started being annoyed by the frequent and sudden request for there ssh key password.
You can follow these steps to mimic the older functionality of macOS remembering your password between sessions and restarts.
ssh-add -K ~/.ssh/id_rsa
id_rsa to match the you want to have remembered (
id_rsa is the default)
Add the following to your
Host * UseKeychain yes AddKeysToAgent yes IdentityFile ~/.ssh/id_rsa
If the file does not exists, create an empty file for it.
As git version 2.10.x, you can also set a key per project using the following command.
git config core.sshCommand "ssh -i ~/.ssh/id_rsa -F /dev/null"
Note that you would still replace the `id_rsa` with the key you wanted to use with that repository.
Original Sources content by:
Apple purposely changed the behaviour for ssh-agent in macOS 10.12 Sierra to no longer automatically load the previous SSH keys, as noted in this OpenRadar and Twitter discussion. The solution above will mimic the old behaviour of El Capitan and remember your password.
ChrisJF on superuser.com
From Git version 2.10.0, you can configure this per repo or globally, so you don't have to set the environment variable any more!
Flimm on superuser.com