Skip to content

Instantly share code, notes, and snippets.

@joseche
Last active November 13, 2015 23:04
Show Gist options
  • Select an option

  • Save joseche/5e5b70227515666a82c7 to your computer and use it in GitHub Desktop.

Select an option

Save joseche/5e5b70227515666a82c7 to your computer and use it in GitHub Desktop.
Multiple Accounts for GitHub

Use different github accounts with key auth

this works with URLs like [email protected]:...., not https

1 - Create a separate key for each account

Use this command:

ssh-keygen -t rsa -C "email address of each account"
# make sure you name the key file accordingly

2 - Add each key to each account

Account Overview -> SSH Public Keys
Upload the content of the public key

3 - Create a host profile for each account in ~/.ssh/config

#---- default
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa

#---- for each account do:
Host github-COMPANY
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_COMPANY

Clone, or set your origin accordingly for each repo

git remote add origin git@github-COMPANY:Company/testing.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment