错误信息如下

xxx@MacBook-Pro xxx-code % git cl       git@gitlab.xxxxxx-inc.com:xxx_fe_organization/xxx-erp-data.git
Cloning 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.xxx
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: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:7
ECDSA 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 rights
and 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 拉取代码成功

tuihou123321
491 声望5 粉丝