Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aghyad/7779162 to your computer and use it in GitHub Desktop.
Save aghyad/7779162 to your computer and use it in GitHub Desktop.
how to work with more than one user and more than one key
To be able to utilize more than one key in your github environment on one computer, and assuming we have the 2 following keys:
~/.ssh/id_rsa_personal_key
~/.ssh/id_rsa_company_key
Create the file ~/.ssh/config with the follwoing content:
### Default (Personal) GitHub
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_personal_key
### Company GitHub
Host company-github
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_company_key
Make sure all the keys added:
$ ssh-add -l ### this should list the keys added
$ ssh-add /path/to/your/key ### to add a key
Also, to be able to track your user contributions separately, make sure you are working with the correct github user:
$ git config user.email ### to list the email of the current user
$ git config --global user.name "USERNAME-HERE" && git config --global user.email USER-EMAIL-HERE ### to update the current working username & email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment