使用git拉取代碼時(shí),遇到這個(gè)問題
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for gitlab.317hu.com has changed,
and the key for the corresponding IP address 116.62.31.5
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:rctUfjaKTvGkv1u/lGCGFf1Ldl8NRAJOCTEAwR3XjGM.
Please contact your system administrator.
Add correct host key in /Users/wanggang/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/wanggang/.ssh/known_hosts:1
ECDSA host key for gitlab.317hu.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.
ssh會(huì)把你每個(gè)你訪問過計(jì)算機(jī)的公鑰(public key)都記錄在~/.ssh/known_hosts。當(dāng)下次訪問相同計(jì)算機(jī)時(shí),會(huì)核對(duì)公鑰。如果公鑰不同,ssh會(huì)發(fā)出警告,避免你受到DNS Hijack之類的攻擊。因此我們現(xiàn)在只需要?jiǎng)h除knows_hosts文件中所對(duì)應(yīng)的公鑰即可
解決:第一種方案
1、ssh-keygen -F 計(jì)算機(jī)名稱(IP)

###例如我的錯(cuò)誤:我使用如下
ssh-keygen -F gitlab.317hu.com
2、得到gitlab.317hu.com的公鑰,以及在所在的行數(shù)
# Host gitlab.317hu.com found: line 1
gitlab.317hu.com,172.16.150.202 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBN+VIPYC1TfkW7kKAPBPd8i7deAc91v+X2CJC9i3Q167JYcZKr661X7saLMWRNThMT+AICqdZc4H0fClgTRVTJA=
wanggangdeMacBook-Pro:111 wanggang$
3、去known_hosts中找到對(duì)應(yīng)的公鑰將其刪除
第二種解決方案:
粗暴點(diǎn),直接刪除known_hosts文件,重新生成一個(gè)
1、刪除舊的

2、執(zhí)行下面命令, 一路回車,不用設(shè)置密碼
ssh-keygen -t rsa -C "wanggang@317hu.com(你自己的賬號(hào))"

如上圖,就已經(jīng)創(chuàng)建成功
3、查看公鑰,輸入命令,得到公鑰
cat ~/.ssh/id_rsa.pub
4、復(fù)制,粘貼到下圖key里即可

參考:
https://blog.csdn.net/xw13106209/article/details/6855294
http://www.anheng.com.cn/news/30032.html