- 这个报错之前有一个另外一个由于未添加ssh key 引起的问题。因为之前不知道每次都要新建gerrit实例。
添加key:
ssh-keygen -t rsa
查看并把公匙添加到git:
cat ~.sshid_rsa.pub
添加私匙:
ssh key
ssh-agent bash
ssh-add id_rsa - 然后在Android Studio中clone项目时出现错误
Unable to negotiate with … port …: no matching key exchange method found. Their offer: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
查了一下,有的帖子说可以添加一个config文件,试了没有用。
还有一个可能是因为客户端和服务器端git版本不一致导致的。解决方法是根据‘their offer’ 分别添加:
$ export GIT_SSH_COMMAND='ssh -o KexAlgorithms=+diffie-hellman-group1-sha1'
$ export GIT_SSH_COMMAND='ssh -o KexAlgorithms=+diffie-hellman-group14-sha1'
成功clone。