通过拉取 gitlab代码报错的解决方案

Posted tuihou123321

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过拉取 gitlab代码报错的解决方案相关的知识,希望对你有一定的参考价值。

错误信息如下

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 拉取代码成功

以上是关于通过拉取 gitlab代码报错的解决方案的主要内容,如果未能解决你的问题,请参考以下文章

关于Gitlab拉取代码没权限的解决方法

git拉取GitLab工程报错Repository not found

git拉取GitLab工程报错Repository not found

RuntimeError: ‘lengths’ argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor(代码片段

离线下IDEA打开拷贝的完整工程,解决工程代码大量报错的问题

macOS 使用 git 从 gitlab 拉取代码提交和推送