(gdb) break *0x972

Debugging, GNU± Linux and WebHosting and ... and ...

Multiple Github Accounts and SSH Identities

I have two github accounts, one for academic work and another for my personal projects. But Github identifies you by your ssh key, you commit account is nowhere written in git@github.com:perso/project.git.

Although Github staff don't advise us to have multiple account, I don't want to mix my personal work with the academic one:

Hi Kevin,

Thanks for getting in touch. I strongly recommend that you do not use multiple personal GitHub accounts. Using multiple personal accounts often leads to confusion, and is almost always unnecessary. I recommend that you consolidate your accounts into a single account.

Thanks, James Dennes (GitHub Staff)"

Solution: Multiple ssh Keys and ssh Configuration

As github identities your account with the ssh key you use for the connection, you just have to create another ssh key:

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/kevin/.ssh/id_rsa): /home/kevin/.ssh/id_rsa_perso
...

and give the public key ~/.ssh/id_rsa_perso.pub to github.

Last thing, to greatly simplify the usage of that second key, tell ssh when to use it or not:

$ cat ~/.ssh/config
Host github.perso
  HostName github.com
  User git
  IdentityFile /home/kevin/.ssh/id_rsa-perso

Now, ssh github.perso is equivalent to ssh git@github.com -i /home/kevin/.ssh/id_rsa-perso. So you can clone your personal repository simply by changing github.com to github.perso in the repository URL:

git clone `git@github.perso:perso/project.git` # or just github-perso:perso/project.git

Wednesday, December 17, 2014 - No comments

Publié dans :