Copy and pasted from: https://mherman.org/blog/managing-multiple-github-accounts/
Let’s look at how to manage multiple Github accounts from one computer. In essence, it’s simply a matter of balancing both your git and ssh configurations - which actually is not as bad as it might seem.
Note: This tutorial is meant for Unix users.
Let’s assume your two Github accounts are named githubPersonal and githubWork, respectively.
Create two SSH keys, saving each to a separate file:
$ cd ~/.ssh
$ ssh-keygen -t rsa -C "your_email@associated_with_githubPersonal.com"
# save it as id_rsa_personal when prompted
$ ssh-keygen -t rsa -C "your_email@associated_with_githubWork.com"
# save it as id_rsa_work when prompted
The above commands setup the following files:
- id_rsa_personal
- id_rsa_personal.pub
- id_rsa_work
- id_rsa_work.pub
$ pbcopy < ~/.ssh/id_rsa_personal.pub
- Go to your Account Settings
- Click “SSH Keys” then “Add SSH key”
- Paste your key into the “Key” field and add a relevant title
- Click “Add key” then enter your Github password to confirm
$ touch config
# githubPersonal
Host personal
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_personal
# githubWork
Host work
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_work
$ ssh-add -D
$ ssh-add id_rsa_personal
$ ssh-add id_rsa_work
$ ssh-add -l
$ ssh -T personal
Hi githubPersonal! You've successfully authenticated, but GitHub does not provide shell access.
$ ssh -T work
Hi githubWork! You've successfully authenticated, but GitHub does not provide shell access.