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 //gitee.com/ysgdaydayup/pingrixuexilianxi.git

2、重新拉取成功 

git pulll

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

添加如下匹配:

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

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

Reference

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

Tags: