Author

Tags

Share article

Besides my regular Github freethinker account, I had to create a new github account for my new job. Problem was how to manage different ssh keys for different github accounts as Github doesn’t allow the same key for more than one account. The Solution is:

1) Create a new alias for github.com in the ~/.ssh/config file.

Host GitHub-readme
Hostname=github.com
IdentityFile=~/.ssh/id_rsa_alt

This alias still points to github.com but when you ssh into github using the new alias, it will use the alternative SSH key. It should be noted that Github recognizes you not by your username but by your ssh key.

Before you go on, do remember to ssh-add the key.

ssh-add ~/.ssh/id_rsa_alt

To verify whether the ssh key has been added or not

ssh-add -l

2) Next, lets verify if our new configuration works with github. To do so, execute ssh -T git@GitHub-readme, where GitHub-readme is the new alias we created in step one with an alternative ssh key.