错误信息如下

xxx@MacBook-Pro xxx-code % git cl       git@gitlab.xxxxxx-inc.com:xxx_fe_organization/xxx-erp-data.gitCloning into 'xxx-erp-data'...@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@The ECDSA host key for gitlab.xxxxxx-inc.com has changed,and the key for the corresponding IP address 8.xxx.xxx.xxxis unknown. This could either mean thatDNS SPOOFING is happening or the IP address for the hostand 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 isSHA256:XX4mhCdJN2p5x4naUlqf8sVAW5i7ffekWFu83QM3bN0.Please contact your system administrator.Add correct host key in /Users/xx/.ssh/known_hosts to get rid of this message.Offending ECDSA key in /Users/xx/.ssh/known_hosts:7ECDSA host key for gitlab.xxxxxx-inc.com 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 rightsand the repository exists.xxx@MacBook-Pro xxx-code % 

重现步骤:

  1. 登陆公司的VPN (代码在公司内网)
  2. 从新生成sshkey: 执行命令 ssh-keygen
  3. gitlab上增加新的sshkey: 执行 open ~/.ssh/id_rsa.pub 获取
  4. git cl xxxx 拉代码 // 报错了

依据报错信息尝试的解决办法:

一、WARNING: POSSIBLE DNS SPOOFING DETECTED!

dns应用的google 8.8.8.8, 8.8.4.4,排除DNS问题

二、The ECDSA host key for gitlab.xxxxxx-inc.com has changed,

依据错误信息找到 https://www.jianshu.com/p/04a... 材料。
执行步骤

  • 清空.ssh内容 // 这一步是要害
  • 执行: ssh-keygen 从新生成 sshKey,再增加到gitlab中
  • 通过 git cl git@gitlab.xxxxx-inc.com:xxxx_organization/xxxx-data.git 拉取代码胜利