Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 2, 2024 07:59 pm GMT

Managing multiple GitHub SSH logins on a single machine

Do you have more than one account for GitHub, i.e. one for professional work dev and another for personal side projects?

If you're using SSH to clone repositories this might help...

Setting up your SSH keys

I won't copy the existing GitHub docs for generating keys

Once you've created the keys you should add them to your GitHub accounts, again their article would be better than mine...

Now that you've got at least 2 SSH keys you need to add some config to ~/.ssh/config, if that file doesn't exist yet you can create it.

In that file, you need to add an entry like this for each GitHub account

Host github.com    Hostname github.com    User git    AddKeysToAgent yes    IdentitiesOnly yes    IdentityFile ~/.ssh/id_fizz

For each one you need to change the Host and the IdentityFile. i.e. if you had a personal and a work account you could set it up like this:

Host github.com    Hostname github.com    User git    AddKeysToAgent yes    IdentitiesOnly yes    IdentityFile ~/.ssh/id_fizzHost work-github.com    Hostname github.com    User git    AddKeysToAgent yes    IdentitiesOnly yes    IdentityFile ~/.ssh/id_buzz

Now you've done that you should be able to be able to test you're connections like so:

$ ssh -T [email protected] <Personal GitHub Username>! You've successfully authenticated, but GitHub does not provide shell access.$ ssh -T [email protected] <Work GitHub Username>! You've successfully authenticated, but GitHub does not provide shell access.

Now you've done this you can clone repos like this:

### personal ###$ git clone [email protected]:fizz/buzz.git### work ###$ git clone [email protected]:fizz/buzz.git

I recently found out how to do it and thought I'd share, there might be better ways of doing it. Please let me know if there is!


Original Link: https://dev.to/mbgeorge48/managing-multiple-github-ssh-logins-on-a-single-machine-1k46

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To