最近接受一个新项目在使用git clone克隆代码时,遇到了如下错误:
Unable to negotiate with xxx.xxx.xxx.xxx: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
fatal: Could not read from remote repository.
从提示来看,这个应该是server的key exchange方法无法匹配导致的。而server支持的算法是:diffie-hellman-group1-sha1
。所以此处应该将client端的算法强制使用diffie-hellman-group1-sha1
。
所以此处需要在~/.ssh/config当中添加如下配置:
host xxx.xxx.xxx.xxx #服务器ip地址
KexAlgorithms diffie-hellman-group1-sha1
identityfile ~/.ssh/xxx.pub #如果不是默认的公钥,此处需要指定一下
之后再次执行git clone命令就可以正常执行了。