9

I'm trying to clone a repo in either cygwin or GitBash (msysgit) using Pageant for ssh keys. I get the following error:

$ git clone git@github.com:username/your-project.git
Cloning into 'your-project'...
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
Connection abandoned.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Yet when trying to debug your ssh connection with gitub it says it works

$ ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '192.30.252.129' to the list of known hosts.
Hi username! You've successfully authenticated, but GitHub does not provide shell access.

And $ ssh-add -l show the same finger print that is listed in my github profile

So the problem is not the one described here: https://help.github.com/articles/error-permission-denied-publickey

chrisan
  • 4,152
  • 4
  • 28
  • 32

2 Answers2

22

I found the solution on this page http://www.bitsandpix.com/entry/git-setup-msysgit-install-with-pageantplink-from-putty/ but re-creating here in hopes it saves someone else time in the future as that page did not show up in google for me easily.

It turns out in order to fully use pageant with cygwin/msysgit you first need to accept the finger print of the server with putty itself.

Simply launch putty and connect to host git@github.com or git@bitbucket.org and it will store that fingerprint. All you will see is a brief flash of a putty session and then it closes.

Now back in cygwin or msysgit you should be able to clone.

Alternatively, if you do not wish to use Pageant for your keys you must unset the environment variable GIT_SSH which points to plink.exe and cygwin / msysgit will accept the server fingerprint on their own (but you no longer will get to use Pageant). This was discovered at http://sourceforge.net/p/forge/site-support/2959/#204c

chrisan
  • 4,152
  • 4
  • 28
  • 32
  • 1
    Many thanks for actually coming back and providing an answer! Why is the git on windows documentation story such a mess? – Sandy Apr 13 '15 at 14:25
  • This also is the trick to get command line git + ssh working properly when installed with Git Extensions. You'll need to download Putty.exe (which is not included in the current distro) and run it. I placed it in the same folder as the other putty tools: Program Files (x86)\Git Extensions\PuTTY – roufamatic Apr 29 '15 at 04:48
  • https://gist.github.com/jbrown123/16ede76b87aab1491c6b1dc809a4e03c (the bitsandpix link is dead) – sam boosalis Apr 04 '20 at 00:17
2

Set GIT_SSH to use TortoisePlink.exe instead of PuTTY's plink.exe. This will allow for popup dialog window to prompt for things (e.g. confirm fingerprint, or enter password). If you use plink.exe through Git, you cannot type in responses to plink.exe prompts.

konyak
  • 10,818
  • 4
  • 59
  • 65