git - 服务器主机密钥未缓存 [英] git - Server host key not cached

查看:27
本文介绍了git - 服务器主机密钥未缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I try to push changes from my local repo to a remote repo. When I type:

git push origin

我收到以下错误:

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

我该如何解决这个问题?我在 Windows 7 的命令行中使用 git.

How can I solve this? I'm using git from the command line in Windows 7.

编辑

当我尝试做一个简单的 ssh

When I try to do a simple ssh

ssh user@hostname

我收到以下错误:

Could not create directory '/c//%HOMEDRIVE%%HOMEPATH%/.ssh'.
percent_expand: unknown key %H

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

Somehow it will not create the directory, because the path is invalid. How to fix this?

@eckes:Edit2

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

My Home is set to %HOMEDRIVE%%HOMEPATH% is this correct?

推荐答案

该消息表示 origin 的主机密钥不存在于您的受信任主机文件中.

The message means that the host key of origin is not present in your trusted hosts file.

为了解决这个问题,打开一个到 origin 的普通 SSH 连接,SSH 会询问你是否要信任远程主机(来自 Git 控制台):

To get around this, open a plain SSH connection to origin and SSH will ask you if you want to trust the remote host (from the Git console):

$ 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 会将其密钥添加到已知主机列表中.

If you trust the remote host (i.e. type yes), SSH will add its key to the list of known hosts.

之后,你应该可以做你的git push origin.

After that, you should be able to do your git push origin.

或者,您也可以手动将 origin 的密钥添加到 .ssh/known_hosts 中,但这需要您遵守 known_hosts 的格式 文件,如 sshd(AUTHORIZED_KEYS 文件格式部分).

As an alternative, you could also manually add the key of origin to .ssh/known_hosts but this requires that you adhere to the format of the known_hosts file as described in the man page of sshd (Section AUTHORIZED_KEYS FILE FORMAT).

这篇关于git - 服务器主机密钥未缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆