Monday, February 6, 2012

Git and RSA identities

Here is the solution I found to be able to use git with a different RSA identity than the rsa_id default one.

My repo on github is logback-android and my user account is espinielli.
I did generate an SSH key as per github help and named it github_rsa:
$ ssh-keygen -t rsa -C "your_email@youremail.com" -f github_rsa

I then added the following section in ~/.ssh/config
# github for espinielli
Host github
HostName github.com
User espinielli
IdentityFile /Users/espin/.ssh/github_rsa


From within the repo directory (I cloned it before via http):
$ git remote add gh ssh://git@github.com/espinielli/logback-android.git

And finally I am able to use it like this:
$ git push gh master