Git异常 # Unable to negotiate with xx.xx.xx.xx port 29418: no matching key exchange method found.

1.异常现象

换机新安装 Git 后,拉代码时出现问题:

Unable to negotiate with 10.18.18.18 port 29418: no matching key exchange method found. Their offer: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
fatal: Could not read from remote repository.

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

2.排查分析

从字面上理解,git 服务器端支持 diffie-hellman-group1-sha1 这种密钥交换方法,而 git 客户端不支持。

3.解决方案

跳到 .ssh 目录:

cd ~/.ssh

在C盘 “用户/当前用户名/.ssh/” 目录下新建一个 config 文件,无扩展名。然后使用写字板等工具打开,输入并保存以下内容:

Host *
KexAlgorithms +diffie-hellman-group1-sha1

如此,即好。
不防再试一下刚刚没有执行成功的 git clone 命令。

如果有遇到提示:Are you sure you want to continue connecting (yes/no/[fingerprint])? 
输入 yes,回车即可。

发布了70 篇原创文章 · 获赞 15 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/itanping/article/details/104415899