This artice assumes you have already created an ssh key (~/.ssh/id_rsa and ~/.ssh/id_rsa_pub) on your machine. I call this the default account. A github account needs your public ssh-key. When you create a second github account, using re-using your ssh-key results in this message:
Key is already in use
ssh-keygen -t rsa -C "email@example.com"
IMPORTANT: WHEN ASKED, YOUR HAVE TO SPECIFY A NAME FOR THE KEY. THIS ARTICLE USES: id_rsa_second
# Default account Host github.com github account HostName github.com User git IdentityFile ~/.ssh/id_rsa # Second account Host github.com-p4e github account HostName github.com User git IdentityFile ~/.ssh/id_rsa_second
When cloning the repo or setting the remote for the second account, you have to change the hostname.
git clone firstname.lastname@example.org:githubaccount/reponame.gitbecomes:
git clone email@example.com:githubaccount/reponame.git