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:
host github.com
HostName github.com
IdentityFile <path to id rsa file>
User git
Now you can do git clone git@github.com:username/repo.git
.
Make sure the permissions on IdentityFile are 400.
Sources
ssh – How to tell git which private key to use? – Super User. http://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use