Managing multiple github.com accounts with ssh keys

May 29, 2014

For various reasons I have two account with github.com. One for work and one for personal. If you find
yourself in a similar scenario and you use ssh access to gihub then this article may provide a useful way
to organize your world.

If you haven’t already done so, go ahead and generate ssh keys for each account on your machine. If you
have them setup already, name them something descriptive so you can tell them apart. From here on I’m going
to refer to “workuser” and “personaluser” as the two github usernames, replace them with your actual usernames
or something else meaningful.

Note in this case we’re making our work account the “default” account by using “Host github.com”. This means
when you copy the clone links from github It’ll Just Work (tm). For your personal repos you’ll need to modify
the hostname to “personaluser.github.com”

Modify hosts for existing repos

If you have existing checked out repos for your personal account you’ll need to modify the config for that repo

cd path/to/my-repo
vim .git/config

modify the references to github.com to be personaluser.github.com, E.G.