github中拉取和提交代碼提醒ECDSA host key for 'github.com' differs from the
最近使用本機(jī)很久未使用的 git 提交代碼,每次提交都會(huì)出現(xiàn) Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '20.205.243.166'? 輸入?yes?才能成功提交或者拉取代碼,查找原因由于 github 更新 RSA key 導(dǎo)致的。

github的解決地址:
https://github.blog/2023-03-23-we-updated-our-rsa-ssh-host-key/
解決方式
1、執(zhí)行:
ssh-keygen -R github.com
2、執(zhí)行:
for ip in $(for i in $(seq -f "140.82.%g.%%g" 112 127); do seq -f $i 1 254; done); do ssh-keygen -R $ip; done
或者
curl -L https://api.github.com/meta | ?jq -r '.ssh_keys | .[]' | sed -e 's/^/github.com /' >> ~/.ssh/known_hosts
我們執(zhí)行第二句,因?yàn)楣倬W(wǎng)也是這么讓我們執(zhí)行的。
其中報(bào)錯(cuò)

是jq命令沒(méi)有 加入jq命令:
curl -L -o /usr/bin/jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe
執(zhí)行還是有報(bào)錯(cuò):

閱讀上面的命令可以知道,jq這個(gè)下載下來(lái)之后 放到git的 /usr/bin/ 文件夾下;
下載地址:https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe

將下載下來(lái)的jq-win64.exe 改名成jq.exe

之后繼續(xù)執(zhí)行:
ssh-keygen -R github.com
curl -L https://api.github.com/meta | jq -r '.ssh_keys | .[]' | sed -e 's/^/github.com /' >> ~/.ssh/known_hosts
發(fā)現(xiàn)還是需要確認(rèn):
之后直接在
known_hosts文件中將
20.205.243.166對(duì)應(yīng)的那行刪除,重新執(zhí)行上面語(yǔ)句就可以了;