Robertino Value asked this question · 6 karma · Mar 21 '13 at 01:54 AM
I spent a whole day trying to trace the source of this error :
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists."
I already tried all the usual suspects listed around the net, and at Atlassian and Github. To no avail.
I usually have about 8 - 10 SSH private keys loaded in Putty Pageant. And I do NOT get this error with Putty and WinSCP. With these 2, I can login over SSH with any number of different SSH identities, simultaneously.
But with TortoiseGit 22.214.171.124 (trying to login to just 1 account) I started seeing this error when I updated msysgit to 126.96.36.199.
I started creating my first 3 repos on Bitbucket 2 days ago. I had 10 SSH keys loaded in Pageant, and I was able to only connect to one Bitbucket account over SSH to push, etc. The other 2 received the error message above consistently.
The issue is easy to reproduce. Remove all private keys from the list in Pageant, and add just the 3 SSH identities meant for logging into Bitbucket. Any Git activity which requires login for the second and third keys will always fail. Remove the top key, and the second one (now at the top) will authenticate without issue. And the third on its own of course will always work. Doing this with just 2 private keys in the list (in all possible combinations of the 3 private keys) gives the same results. The one at the top is always used/offered to any request. Anything below it is not used/offered.
With only one of the 3 private keys in the list, there is never a problem as long as you attempt to login to the corresponding account. When attempting to login to a non-corresponding account, Pageant sometimes pops an error "Couldn't load this key (unable to open file)". After pressing OK to dismiss the error popup, the push would fail with the "Permission denied (public key)" error. I usually get this error when I try to load a public key into Pageant. That's why it's so weird.
I first saw this with TortoiseGit 188.8.131.52 and msysgit 184.108.40.206. Upgrading to 220.127.116.11 and 18.104.22.168 respectively didn't change a bit. So I blamed Tortoisegit and completely uninstalled and ran CCleaner to rid off most.
I installed SourceTree, and experienced the same problem. I have to make sure that the private key of the repo I want to work with is at the top of the list in Pageant. Which pretty much negates the multiple Repo tabs in SourceTree.
So I suspect that this is a Git problem. What I'm looking for is confirmation. I'm about to bury DVCS again, for another 3 years or so.