Reputation: 85
The problem
When I test my ssh connection with github using ssh -T [email protected]
, the username it shows is incorrect -
Hi <WRONG USERNAME>! You've successfully authenticated, but GitHub does not provide shell access.
Accordingly, when I try to clone with SSH I get a fatal error saying I don't have permission to access it.
What I have tried / checked
git config --global user.name
.Other notes
Any and all help is greatly appreciated.
Upvotes: 2
Views: 3782
Reputation: 487705
See VonC's answer, and note that if you're using an ssh agent, you can point the configured identity file to the public key, so as to select the appropriate public/private keypair to send to GitHub. The ssh code will then pick up the private key from the agent.
(I've found that when you are not using the ssh agent, ssh won't pick up the private key if you point it to the public key file, even if both files are present on the machine, which is sort of annoying. Another way to put this is: if you do use the agent, IdentityFile
can be either file, and then you can store only the public key on intermediate machines and jump-hosts, which generally is a good idea. But if you do not use the agent, you obviously must store both public and private keys on the machine, and then IdentityFile
must name the private key of the pair. Hence, if you always use the agent, you can use the same ssh config file everywhere, but if you sometimes use the agent, you cannot use the same ssh config file everywhere.)
Upvotes: 0
Reputation: 1323045
I followed the steps in this FAQ and updated .ssh/config
In order for that config entry to be used (meaning to use the right private key referenced by IdentityFile
), you need to use the Host
entry from that %USERPROFILE%\.ssh\config
file in your SSH URL:
Host ghuser2
Hostname github
User git
IdentityFile /path/to/user2/private-key
Your URL become
cd c:\path\to\repo
git remote set-url origin ghuser2:<user2>/<repo.git>
Upvotes: 2