git出错"no matching key exchange method found"

问题描述
今天升级Ubuntu系统到16.04之后,之前通过git管理的一个项目add和commit之后无法push到服务器。每次提交都报以下错误:

Unable to negotiate with xx.xx.x.xxx port xxxx: 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方法,因此无法正常建立链接。

解决方案
解决方案有以下两个

方案一
在project directory/.git/config文件中的ssh 后面添加下面这段代码

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1

1
方案二
在.ssh目录下面新建一个config文件并在config文件中添加以下代码

Host xx.xx.x.xxx
KexAlgorithms +diffie-hellman-group1-sha1

其中 xx.xx.x.xxx为服务器的ip地址或者域名

比较
个人觉得方案二好一些,也是目前我目前采用的方案

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值