【git】git拉取项目报错Host key verification failed.

1、报错现象

> git pull
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ED25519 key sent by the remote host is
SHA256:YznZWVrxlfumZbbLHu5yvbAv40PyX//0R31JP/fbGjg.
Please contact your system administrator.
Add correct host key in /c/Users/Administrator/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /c/Users/Administrator/.ssh/known_hosts:4
Host key for xxx.xxx.xxx 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.

 

2、原因

由于公司gitlab服务器迁移

 

3、解决方案

方法1

手动删除 /c/Users/Administrator/.ssh/known_hosts中服务器相关的信息(换成自己的目录)

 

方法2

 执行命令亦可

ssh-keygen -f "/home/test/.ssh/known_hosts" -R "你的服务域名或者ip"

生成新的配对公钥配置即可 

 

4、重新执行拉取代码

git pull

 重新向/c/Users/Administrator/.ssh/known_hosts添加即可

 

posted @ 2023-09-06 10:47  代码诠释的世界  阅读(1154)  评论(0编辑  收藏  举报