Git vs SSH key passphrases

Git itself is an amazing tool. It helps developers to track every little change in their code easily. But if you use git over ssh then you need to (probably) type your ssh key every time you push code to the remote repository and it can be really annoying.

This behavior can be prevented with relatively easy steps on *nix platforms (Linux or macOS) or Windows (with MinGW environment mostly installed with Git for Windows).


macOS since version 10.12.2 (Sierra) added a possibility to store ssh passphrase in user’s Keychain. You just need to create file:


with following content:

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

Linux or Windows (MinGW)

You don’t necessarily need to create or update any file on Linux. You just have to type a few commands:

$ eval $(ssh-agent)
$ ssh-add -k

The option -k will save your key into the keychain. If you have more than one ssh key then you will need to specify a path to the key you want to store:

$ ssh-add ~/.ssh/id_rsa_custom -k