I created two SSH keys: ~/.ssh/id_ed25519
and ~/.ssh/dr_dror_id_ed25519
. I also uploaded their public parts to two different GH account (personal and work, respectively). Next, I also added the following ~/.ssh/config
:
Host drorata-personal
Hostname github.com
User git
IdentityFile ~/.ssh/id_ed25519
Host dr-dror
Hostname github.com
User git
IdentityFile ~/.ssh/dr_dror_id_ed25519
Now, whether I try:
ssh -T git@drorata-personal
or
ssh -T git@dr-dror
I get the same response:
Hi drorata! You've successfully authenticated, but GitHub does not provide shell access.
Where does drorata
come from? I am guessing it's the username I have in my private account. What am I missing?
I suspect this is ssh-agent trying all the identities that have already been added; IdentityFile
would just specify any that need to be added for that specific Host
match. You should be able to confirm this with ssh -Tv git@dr-dror
, which will give the verbose output of the connection attempt (including, but not limited to, the specific key used to authenticate).
If my suspicion is correct, then you can add IdentitiesOnly yes
to each stanza to have the agent use only the specified key(s) for the Host
match. Once that's done, both ssh -T
commands should return the correct username.