If you want to have repos from two different Github users on the same machine, follow this steps:
- Generating a new SSH key
- IMPORTANT: save your
id_rsa
to a different file, ex:id_rsa_second_user
- IMPORTANT: save your
- Adding the new SSH key to GitHub
- Add an alias to your ssh config editing
$HOME/.ssh/config
:
Host second-user-github
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_second_user
- Test both your connections with these commands:
$> ssh -T [email protected]
Hi <NORMAL_USER>! You've successfully authenticated, but GitHub does not provide shell access.
$> ssh -T git@second-user-github
Hi <SECOND_USER>! You've successfully authenticated, but GitHub does not provide shell access.
- Now you are ready to clone repos with the second user. Remember to change the repo url when you clone it:
# Normal repo url: [email protected]:USERNAME/REPO_NAME.git
# Replace to: git@second-user-github:USERNAME/REPO_NAME.git
$> git clone git@second-user-github:USERNAME/REPO_NAME.git