1

I have 2 git accounts on my mac for which I have 2 sets of public and private keys.
I have a config file in /.ssh to manage those accounts, which looks like this:

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

Host github-user2
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa_user2

Code from these accounts are to be pushed to 2 different remote repositories for which I set their different remotes in their respective directories using following command:

git remote add origin github.com:xyz_user/abc.git
git remote add origin github-user2:pqr_user/def.git

I am successfully able to push to these repos from both accounts.
When I use ssh,

ssh-add -l

shows private keys for both of the accounts added.
But

ssh -T github.com
ssh -T github-user2

both gives the following message:

"Hi user2! You've successfully authenticated, but GitHub does not provide shell access."

1 more thing that I have noticed, even If there is no key listed with " ssh-add -l"

ssh -T github.com & ssh -T github-user2 provide successful authenticate message.

How will I differentiate between both the accounts while making ssh connection?
Where does ssh -T authenticate from?

Manu
  • 46
  • 4

1 Answers1

1

How will I differentiate between both the accounts while making ssh connection?

You won't really: both public keys have been registered in the same GitHub account, so as far as GitHub is concerned, both ssh authenticate you as 'user2'.

Where does ssh -T authenticate from?

It is looking in the ssh keys section of your Account profile.
Both public keys are registered there, as explained in the GitHub help page on "Generating SSH Keys".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hey Von, thanks for replying. But, both the public keys are registered in different GitHub account. – Manu Jul 14 '13 at 16:10
  • @Manu Is it possible that the public keys are *duplicated* in both GitHub accounts? – VonC Jul 14 '13 at 16:25
  • @Manu also, see here (https://gist.github.com/jexchan/2351996) an example of a successful two-accounts ssh setup. – VonC Jul 14 '13 at 16:28
  • Unfortunately both the public keys are different :( – Manu Jul 15 '13 at 08:18
  • @Manu just to check, can you try your `ssh -T github.com` from a different computer, to see if still 'User2' is mentioned? – VonC Jul 15 '13 at 08:34
  • Although I am able to push to both accounts successfully. I want to know, why is ssh -T github.com and ssh -T github-user2 resulting in same message ? – Manu Jul 15 '13 at 08:49
  • @Manu they shouldn't be, since the config file reference two different private keys, with two public keys registered in two different GitHub accounts. Try, just in case, to check `git config user.name` and `git config user.email`. – VonC Jul 15 '13 at 08:53