Skip to content

Instantly share code, notes, and snippets.

@Johnsalzarulo
Last active September 27, 2018 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Johnsalzarulo/dbbeea3a778cdef8d1655fefb6a42922 to your computer and use it in GitHub Desktop.
Save Johnsalzarulo/dbbeea3a778cdef8d1655fefb6a42922 to your computer and use it in GitHub Desktop.
Multiple Github Accounts One Computer

Setting Up Multiple Github Accounts / SSH Keys on one machine

Sometimes you may find yourself needing to have multiple github accounts set up able to push and pull to different repositories where different usernames have access. This guide is intended to be breadcrumbs for those who are struggling.

I really struggled on this one.

Here's the basic steps:

  • Generate a new SSH key
  • Add this key to your ssh settings
  • Copy this key into your github account
  • Then, you'll be able to set the remote for the repo from the compand line.

Here's what I did:

Generate a new ssh key in your comand line with the email associated with the account (in my case)

ssh-keygen -t rsa -b 4096 -C “help@withbetter.com"

Compand line will then prompt you: Enter file in which to save the key (/Users/johnsalzarulo/.ssh/id_rsa):

Be careful not to simply toss it into the current path of your id_rsa - it will overwrite your current ssh key if you ahve one configured.

So - in my case I did:

/Users/johnsalzarulo/.ssh/id_rsa_better

Then it will prompt: Enter passphrase (empty for no passphrase): This is requried.

Then for MacOS you need to revise your ssh config: (Atom is my editor of choice)

atom ~/.ssh/config

I edited mine to have the following:

Host *
 AddKeysToAgent yes
 UseKeychain yes
 IdentityFile ~/.ssh/id_rsa
 IdentityFile ~/.ssh/id_rsa_better

Then added this new key: ssh-add -K ~/.ssh/id_rsa_better

Generated - now it has to be added to the Github account:

In GitHub Settings select "SSH and GPG Keys"

Then "New SSH Key"

Copy out your generated key with:

pbcopy < ~/.ssh/id_rsa.pub

THEN you can go into command line and

git clone git@github.com:Bondfire/material.git

or

git remote set-url git@github.com:Bondfire/material.git

Hope it helps!

pbcopy < ~/.ssh/id_rsa.pub

(This copies it)

THEN you can go into command line and

git clone git@github.com:Bondfire/material.git

I had to : git remote set-url git@github.com:Bondfire/material.git

Resources / References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment