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:

1
2
3
4
host miloske.tk
  HostName miloske.tk
  IdentityFile /home/milos/secure/my-key
  User git

 

Leave a Reply

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


CAPTCHA Image
Reload Image