Github with multiple keys
While I was working with my Opensource project https://github.com/OnToology/OnToology
I needed to have multiple Github keys for django tests. Below is how I did it:
Assumptions:
- You are running Linux, Unix or Mac.
- You have git installed.
- You have github account.
- You know the basics of git.
1- First of all, generate the first key and second key (running the same command twice) don't forget to name them differently (in this example I named them id_rsa_key1 and id_rsa_key2)
ssh-keygen -t rsa -C "your_email@youremail.com"
2-Add the generate keys, id_rsa_key1.pub and id_rsa_key2 to Github (follow the intstructionin the first link the resources below )3- Run the below command to add the two keys
ssh-add ~/.ssh/id_rsa_key1
ssh-add ~/.ssh/id_rsa_key2
4- Create a file ~/.ssh/config and write the below
Host github.com-user1
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_key1
Host github.com-user2
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_key2
5- User one Github key/user
$ git config user.name "user1" $ git config user.email "user1@gmail.com"
OR $ git config user.name "user2" $ git config user.email "user2@gmail.com"
Note: What works for me is to have only one key loaded,
to check loaded keys run "ssh-add -l", and to remove a
key use "ssh-add -d yourkeydirectory".
I created somefunction, maya separate script lateron on to manipulate different kinds of keys https://github.com/OnToology/OnToology/blob/master/OnToology/tests/__init__.py
https://help.github.com/articles/generating-ssh-keys/
https://gist.github.com/jexchan/2351996
Comments
Post a Comment