Mac OS (High Sierra) here. I have an SSH key, example-gh-user
, and when I run pbcopy < ~/.ssh/example-gh-user.pub
and paste it into an editor I see:
ssh-ed25519 <SOME_REALLY_LONG_ALPHANUM> me@example.org
Obviously for security reasons I am replacing the actual value of <SOME_REALLY_LONG_ALPHANUM>
and me@example.org
with the dummy values above. But everything looks ok.
On GitHub, I have a user, example-gh-user
, that is using the me@example.org
email, and I can log in with that user and see all my repos. Everything appears fine.
I have followed the GitHub guide on adding an SSH key to my example-gh-user
GitHub account. Hence, this SSH key should be associated with the same email address that my GH account is associated with.
In my ~/.ssh/config
file, I have the following entries:
Host example-dev
Hostname github2.com
AddKeysToAgent yes
IdentityFile ~/.ssh/example-gh-user
Host github.com
User git
Hostname github.com
AddKeysToAgent yes
PreferredAuthentications publickey
IdentityFile ~/.ssh/example-gh-user
So far, so good, I think.
However, when I run the following from the command line:
ssh -Tv git@github.com
I get a huge dump of output that ends, interestingly-enough, with this:
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi my-old-gh-user! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3452, received 2724 bytes, in 0.1 seconds
Bytes per second: sent 28403.1, received 22413.1
debug1: Exit status 1
Look at that! my-old-gh-user
! That's an old GH user that I haven't used in years!
Where is SSH and/or git/GitHub looking to grab that my-old-gh-user
from?! Does SSH cache old data some how? If I understand how everything works correctly, ~/.ssh/config
clearly directs SSH to use ~/.ssh/example-gh-user
when connecting as git
user to github.com
, right? Where am I going awry?