之前通过git管理的一个项目,今天直接用eclipse通过ssh加入工程后,每次通过git命令行pull代码都报以下错误:
Unable to negotiate with 21.12.1.167 port 29418: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
查了些资料,分析是git server和client使用的ssh key解析算法不一致造成的,client因为系统升级的原因默认使用新的key exchange method而服务器只提供diffie-hellman-group1-sha1方法,因此无法正常建立链接。
解决的方案是在.ssh目录下面新建一个config文件并在config文件中添加以下代码。
Host xx.xx.x.xxx
KexAlgorithms +diffie-hellman-group1-sha1
其中 xx.xx.x.xxx为服务器的ip地址或者域名,这个config文件可以通过.git文件夹下的复制后修改。