Using custom private SSH key for git

When you are working with git, either your private or your company’s git server or with github it is much nicer to be able to push/pull/clone without having to enter the password every time. Furthermore, SSH keys are safer. However, the default option is to keep the private key in ~/.ssh/ folder which is not encrypted (unless your /home folder is encrypted). SSH client has the -i which allows you to specify the location of your private key, but this won’t work with git.

Fortunately there is a way. All you need to do is create one config file (called ‘config’) in ~/.ssh/. Here is how it should look like:

  IdentityFile /home/milos/secure/my-key
  User git


Read More