In order to access multiple github accounts from one computer you need to :
Step 1 - Generating SSH keys:
cd ~/.ssh
ssh-keygen -t rsa -C "[email associated with your github account #1]"
# save it as id_rsa_git_account1 when prompted
ssh-keygen -t rsa -C "[email associated with your github account #2]"
# save it as id_rsa_git_account2 when prompted
As the result of executing these commands, the following files will be generated:
Step 2 - Adding ssh keys to your github account
Using this command you can copy the key to your clipboard:
pbcopy < ~/.ssh/id_rsa_git_account1.pub
Now as the key is in your account, all you have to do is to open your github account and:
Step 3 - Create a configuration file to manage the separate keys
~/.ssh/
# githubAaccount1 Host account1
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_git_account1# github Account2
Host account2
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_git_account2
Step 4 - Update Stored Identities:
ssh-add -D
Add new keys:
ssh-add id_rsa_git_account1
ssh-add id_rsa_git_account2
Test to make sure new keys are stored
ssh-add -l
Testing Push / Pull
touch readme.md
$ git ini
$ git add .
$ git commit -am "first commit"
$ git remote add origin git@account1:githubPersonal/test-personal.git
$ git push origin master
Publish Date: 2015-04-08