首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >git -服务器主机密钥未缓存

git -服务器主机密钥未缓存
EN

Stack Overflow用户
提问于 2011-02-08 17:31:08
回答 20查看 130.6K关注 0票数 106

我尝试将更改从本地存储库推送到远程存储库。当我键入时:

代码语言:javascript
复制
git push origin

我得到以下错误:

代码语言:javascript
复制
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 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
Connection abandoned.
fatal: The remote end hung up unexpectedly

我该如何解决这个问题呢?我在Windows7的命令行中使用git。

编辑

当我尝试做一个简单的ssh时

代码语言:javascript
复制
ssh user@hostname

我得到以下错误:

代码语言:javascript
复制
Could not create directory '/c//%HOMEDRIVE%%HOMEPATH%/.ssh'.
percent_expand: unknown key %H

不知何故,它不会创建目录,因为路径无效。如何解决这个问题?

@eckes:Edit2

我的家设置为%HOMEDRIVE%%HOMEPATH%是正确的吗?

EN

回答 20

Stack Overflow用户

回答已采纳

发布于 2011-02-08 17:39:01

该消息表示origin的主机密钥不在受信任的主机文件中。

要解决此问题,请打开到origin的普通SSH连接,SSH将询问您是否要信任远程主机(从Git控制台):

代码语言:javascript
复制
$ ssh 127.0.0.1
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
RSA key fingerprint is <FINGERPRINT>.
Are you sure you want to continue connecting (yes/no)?

如果您信任远程主机(即类型为yes),则SSH会将其密钥添加到已知主机列表中。

在此之后,您应该能够执行git push origin

或者,您也可以手动将origin的密钥添加到.ssh/known_hosts,但这要求您遵循sshd手册页中所述的known_hosts文件格式( AUTHORIZED_KEYS file format 一节)。

票数 54
EN

Stack Overflow用户

发布于 2012-09-17 01:19:28

对于那些通过标准命令提示符使用PuTTY在Windows上设置MSYS Git的用户,将主机添加到PuTTY缓存的方法是运行

代码语言:javascript
复制
> plink.exe <host>

例如:

代码语言:javascript
复制
> plink.exe codebasehq.com

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 2e:db:b6:22:f7:bd:48:f6:da:72:bf:59:d7:75:d7:4e
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)

只需回答y,然后Ctrl+C其余部分。

不过一定要检查指纹。这个警告是有充分理由的。某些git服务的指纹(请编辑以添加更多内容):

16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48

  • GitHub
票数 164
EN

Stack Overflow用户

发布于 2012-02-22 06:22:05

尝试在Git Bash提示符下执行"set | grep -i ssh“

如果你的设置和我的一样,你可能有以下设置:

代码语言:javascript
复制
GIT_SSH='C:\Program Files (x86)\PuTTY\plink.exe'
PLINK_PROTOCOL=ssh
SVN_SSH='"C:\\Program Files (x86)\\PuTTY\\plink.exe"'

我做了一个

代码语言:javascript
复制
unset GIT_SSH
unset PLINK_PROTOCOL
unset GIT_SVN

在那之后它起作用了,..我猜putty将它的密钥保存在其他地方,即$HOME/.ssh或其他什么地方...(我还在$HOME设置为"C:\Users\usrnam“而不是"/C/Users/usrnam/”的机器上遇到了一个问题。

无论如何,您的里程数可能会有所不同,但这为我解决了问题。:-)

(可能只做未设置的GIT_SSH就足够了,但我很幸运)

注意:如果unset对你不起作用,试试这个:

代码语言:javascript
复制
set GIT_SSH=
票数 81
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4931384

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档