问题解决:Git error: no matching host key type found. Their offer: ssh-rsa

5,085 阅读1分钟

如需转载,请标明原文出处: https://juejin.cn/post/7023284845333708836 ,谢谢。

问题

今天在公司改完一个Bug,准备提交代码。Git提交、推送均报错。

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch --no-tags origin
Unable to negotiate with 10.10.10.105 port 7999: 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.

关键报错信息就是这一句

no matching host key type found. Their offer: ssh-rsa

原因

昨天升级了一下Git,不知道和这个有没有关系。头大。

解决

用记事本打开~/.ssh/目录(e.g. C:\Users\Admin\.ssh)下的config文件。增加以下配置。

Host *
    KexAlgorithms +diffie-hellman-group1-sha1
    HostkeyAlgorithms +ssh-dss,ssh-rsa
    PubkeyAcceptedKeyTypes +ssh-dss,ssh-rsa

每个人的情况都不一样,我这个电脑的确是这样配置解决了,但是我同事电脑没有config文件也能正常提交、推送。所以。。。此方案仅供参考。

参考资料

stackoverflow.com/questions/3…