Skip to content

Instantly share code, notes, and snippets.

@guumaster
Created February 23, 2019 19:00
Show Gist options
  • Save guumaster/6883434546123b131c548250f1ba5531 to your computer and use it in GitHub Desktop.
Save guumaster/6883434546123b131c548250f1ba5531 to your computer and use it in GitHub Desktop.
Multiple SSH Keys for Github

How to manage two Github users

If you want to have repos from two different Github users on the same machine, follow this steps:

Host second-user-github
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_second_user
  • Test both your connections with these commands:
$> ssh -T git@github.com
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: git@github.com:USERNAME/REPO_NAME.git
# Replace to: git@second-user-github:USERNAME/REPO_NAME.git

$> git clone git@second-user-github:USERNAME/REPO_NAME.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment