git pull拉取代码时WARNING: POSSIBLE DNS SPOOFING DETECTED!

报错

: command not found
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for pha.i.mobigroup.cn has changed,
and the key for the corresponding IP address 47.104.6.100
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
SHA256:w1MSu5mdmkm0SZ4KLFJXRkOhmvNz3lViS1cUofgjcz4.
Please contact your system administrator.
Add correct host key in /c/Users/Dell/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /c/Users/Dell/.ssh/known_hosts:1
ECDSA host key for pha.i.mobigroup.cn has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

原因

ssh会把你每个你访问过计算机的公钥(public key)都记录在~/.ssh/known_hosts。当下次访问相同计算机时,OpenSSH会核对公钥。如果公钥不同,OpenSSH会发出警告, 避免你受到DNS Hijack之类的攻击。我在上面列出的情况,就是这种情况。
根据提示可以看到主要是.ssh/known_hosts的发送冲突,它是代码库对应的公钥。

解决
  1. 手动删除修改known_hsots里面的内容;
    rm -f ~/.ssh/known_hosts
    优缺点:需要每次手动删除文件内容,一些自动化脚本的无法运行(在SSH登陆时失败),但是安全性高;

  2. 修改配置文件“~/.ssh/config”,加上这两行,重启服务器。
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    优缺点:SSH登陆时会忽略known_hsots的访问,但是安全性低;

你可能感兴趣的:(git pull拉取代码时WARNING: POSSIBLE DNS SPOOFING DETECTED!)