[已解决]使用git拉代码时报错: Unable to negotiate with **** port 22: no matching host key type found.

在克隆阿里云代码时报了下方的错

Unable to negotiate with 47.98.49.44 port 22: no matching host key type found. Their offer: ssh-rsa
fatal: Could not read from remote repository.

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

在网上搜一波都是让生成ssh公钥然后部署到服务器上,然后折腾一晚上,以为就是这个问题,但还是不行。

后来发现原来是当时本来本地已经有生成过公钥了,但我怕重复,所以删掉了以前的,还连着删了几个其他文件,无语!

原因可能是新的ssh客户端不支持ssh-rsa算法,要修改本地配置重新使用ssh-rsa算法

解决方法:

在生成公钥的文件夹里(一般在当前用户目录下的.ssh文件中)创建一个config文件(没有后缀),用文本文档格式打开,添加下方内容

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

 

保存

然后再试克隆仓库,成了!


版权声明:本文为weixin_51443484原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_51443484/article/details/125944815