无法“git pull” - 主机密钥验证失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21087695/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Not able to "git pull" - Host key verification failed
提问by Richard
I've got root access to our production server and I want to deploy the latest version in git to the server but I'm running into the error below when I "git pull" on the folder I want to update.
我对我们的生产服务器有 root 访问权限,我想将 git 中的最新版本部署到服务器,但是当我在要更新的文件夹上“git pull”时遇到以下错误。
I've browsed around a bit, but can't find a clear answer on what to do..
我已经浏览了一些,但找不到关于该怎么做的明确答案..
The staging server runs on the same machine, but just in a different folder and when I pull
on that folder it all goes fine.
临时服务器在同一台机器上运行,但只是在不同的文件夹中,当我pull
在该文件夹中时,一切正常。
I'm not very experienced when it comes to Linux, so please help me out with a clear answer on how to fix :-)
我对 Linux 的经验不是很丰富,所以请帮助我明确回答如何修复:-)
Otherwise I have access to anything I need
否则我可以访问我需要的任何东西
p.s. This has worked in the past, so I'm assuming it's got something to do with the SSH key
ps 这在过去有效,所以我假设它与 SSH 密钥有关
Error:
错误:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for www.site.org has changed,
and the key for the corresponding IP address x.x.x.x
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
*************
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:1
remove with: ssh-keygen -f "/root/.ssh/known_hosts" -R gitlab.site.org
ECDSA host key for gitlab.site.org has changed and you have requested strict checking.
Host key verification failed.
回答by fedorqui 'SO stop harming'
In the log you see the following text:
在日志中,您会看到以下文本:
(...) Please contact your system administrator. Add correct host key in /root/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /root/.ssh/known_hosts:1 remove with: ssh-keygen -f "/root/.ssh/known_hosts" -R gitlab.site.org ECDSA host key for gitlab.site.org has changed and you have requested strict checking. Host key verification failed.
So it is a matter of performing the command that is suggested there:
所以这是执行那里建议的命令的问题:
ssh-keygen -f "/root/.ssh/known_hosts" -R gitlab.site.org
回答by abhiklpm
Windows:
视窗:
- Go to
/Users/Abhilash/.ssh/known_hosts
and delete the contents in it and save.
- 转到
/Users/Abhilash/.ssh/known_hosts
并删除其中的内容并保存。
Linux / Mac:
Linux/Mac:
- Go to
~/.ssh/
- nano known_hosts
- remove content inside and save
ctrl+O
- 去
~/.ssh/
- nano known_hosts
- 删除里面的内容并保存
ctrl+O
Note:You will be promted to save the key while pushing again.
注意:再次按下时,系统会提示您保存密钥。
回答by Purnendu roy
I have also faced the same issue after following these steps it worked for me.
按照这些对我有用的步骤后,我也遇到了同样的问题。
For macOS:
对于 macOS:
Step 1: Go to Folder or use command+shift+g
Step 2: type "~/.ssh/"
Step 3: Open "known_hosts" file and Remove all the content
Step 4: Now Open terminal and pull from another branch, It will ask for password give your system password.
It will work surely.
它肯定会起作用。
回答by danfromisrael
if you'd like to remove this message permanently you can edit your ssh config file (~/.ssh/config
) to include:
如果您想永久删除此消息,您可以编辑您的 ssh 配置文件 ( ~/.ssh/config
) 以包括:
Host {YOUR HOST HERE}
StrictHostKeyChecking no
UserKnownHostsFile /dev/null