How to tell git to use a specific private key

When setting up automatic deployment on a software project using git, you may want your server to be able to automatically pull changes from the repository. Popular repo hosts like Github and Bitbucket will usually need your server’s public SSH key to allow access. Assuming you have a server with multiple SSH keys, it may become important for you to specify which SSH key to use for specific users when using git. Here I explain how to make git use a specific private key when accessing Github.

In ~/.ssh/config, add:

 IdentityFile <path to id rsa file>
 User git

Now you can do git clone

Make sure the permissions on IdentityFile are 400.


ssh – How to tell git which private key to use? – Super User.

Leave a Reply

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