Setting up GitHub to use multiple servers with different keys

Sometimes you want to connect to two different repositories with two different accounts.

To do this, you’ll need to create/modify your ~/.ssh/config file with the following stanza.

#Personal Repository on Public GitHub
Host github.com
    HostName github.com
    User git@github.com
    IdentityFile ~/.ssh/id_rsa_GitHub_Personal

You can rename your existing id_rsa file to whatever you want, just as long as you specify which file to use for which service in the IdentityFile field.

I’ve used to to connect to my personal GitHub public repository and my Employer’s internal GitHub repository from the same computer with different keys.  (Because you shouldn’t be sharing keys.)  But I haven’t tried doing this with multiple GitHub accounts on the same server yet.  Maybe I’ll look into that next week.  =)

Leave a Reply

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