9

我正在尝试使用 Pageant 克隆 cygwin 或 GitBash (msysgit) 中的存储库作为 ssh 密钥。我收到以下错误:

$ 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.

然而,当尝试使用 gitub 调试您的 ssh 连接时,它说它可以工作

$ 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.

$ ssh-add -l显示我的 github 个人资料中列出的相同指纹

所以问题不是这里描述的问题:https ://help.github.com/articles/error-permission-denied-publickey

4

2 回答 2

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

于 2014-08-05T12:24:30.640 回答
2

将 GIT_SSH 设置为使用TortoisePlink.exe而不是 PuTTY 的plink.exe. 这将允许弹出对话窗口提示一些事情(例如确认指纹,或输入密码)。如果plink.exe通过 Git 使用,则无法输入对 plink.exe 提示的响应。

于 2015-11-04T20:15:19.920 回答