Unable to negotiate with xx.xxx.xxxx port 22: no matching host key type found. Their offer: ssh-rsa(解決的兩種方式)


異常問題:

  下班之前升級了一下Git的版本,結果第二天過來拉取遠程最新代碼的時候就提示了下面的異常問題:

Unable to negotiate with xx.xxx.xxxx port 22: no matching host key type found. Their offer: ssh-rsa
Git failed with a fatal error.
Git failed with a fatal error.
Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists. 

問題分析:

  通過翻譯上面的報錯信息大概說的是沒有匹配到類型為ssh-rsa的主機秘鑰。或者是可能你的代碼倉庫權限沒有了。

於是我上代碼托管平台看了下我的項目權限是否被修改了,結果發現沒有變更(這個可能性別排除了)。然后既然是ssh-rsa秘鑰的問題,我就是試着把本機的ssh-key重生生成了一次再去托管平台添加,然后依舊還是包這個錯。

解決方案一,切換成HTTPS的方式

1、修改本地代碼關聯的遠程地址

git remote set-url origin https://gitee.com/ysgdaydayup/pingrixuexilianxi.git

2、重新拉取成功 

git pulll

解決方案二、在.ssh文件中創建config文件並添加配置 

添加如下匹配:

第一行說明對所有主機生效,當然你也可以指定對應主機地址!

Host *
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa

Reference

https://www.cnblogs.com/daibeisi/p/15662546.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM