尝试克隆 git 存储库后,Win 控制台挂起

mak*_*aks 5 windows git ssh putty

我有一个要克隆的远程仓库。我已经设置了 pageant.exe 并添加了私钥。还添加了指向 plink.exe 的 GIT_SSH 变量。在克隆命令之后我得到这样的输出

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.
...
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n)
Run Code Online (Sandbox Code Playgroud)

当打字yn没有任何反应时,控制台只是挂起,我必须终止命令Ctrl+C

为什么会发生这种情况以及如何解决这个问题?

mak*_*aks 3

经过几个小时的调查,我终于找到了解决方案。putty 必须知道您要连接的主机,即主机必须是known_hostputty 的。Putty 存储有关know_hosts注册表 HKEY_CURRENT_USER\SoftWare\SimonTatham\PuTTY\SshHostKeys项的信息。要强制 putty 将有关该主机的信息添加到注册表项,我们可以使用您的私钥通过 putty.exe 进行访问。第一次访问时,putty 会要求您将该主机添加到known_hosts. git clone 命令成功完成后。

也许这对某人有帮助,因为乍一看并不明显

  • 该死的不完整的接受答案天哪。@andrybak 说得非常正确。只需调用“%GIT_SSH%”thehost.com``,您就可以选择“y”。您将体验@andrybak 的解释 (5认同)
  • “真正的”问题是 git (我相信它是“git for windows”)不会将输入传递给任何询问“将密钥存储在缓存中?(y/n)”的进程(它可能是 ssh 程序之一 - putty 或叮当)。 (2认同)