Issue with cloning git repository

2020-05-25 06:40发布

I am trying to clone the git repository and i am getting error

Unable to negotiate with <server>: no matching key exchange method found.
Their offer: diffie-hellman-group1-sha1
fatal: Could not read from remote repository.

I edited ~/.ssh/config and added

Host somehost.example.org
KexAlgorithms +diffie-hellman-group1-sha1"

but still I am getting same error.

Other solution is to use the command ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 user@127.0.0.1 -p 2222 but I am getting connection refused with port no 22 as well.

I am using windows machine.

标签: git ssh
7条回答
混吃等死
2楼-- · 2020-05-25 07:11

I am using windows, for my case git clone fails in Jenkins (running under system user).

Adding

Host somehost.example.org
   KexAlgorithms +diffie-hellman-group1-sha1

into ~/.ssh/config will make the clone running as the current user works.

For other users, the OpenSSH won't pick up the config. I have to add the above config into the global config file: "C:\Program Files\Git\etc\ssh\ssh_config" to make it work.

查看更多
趁早两清
3楼-- · 2020-05-25 07:22
touch ~/.ssh/config

attach my ssh config for people who come across the same issue

## use kex algorithm ##
Host 10.172.4.66
    KexAlgorithms diffie-hellman-group1-sha1

## Avoid Write failed : boken pipe issue ##
ServerAliveInterval 120
TCPKeepAlive no

use larger postBuffer if come accross another issue

fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
$ git config --global http.postBuffer 10000000000000000000000000000000

$ git clone ssh://xxx xx
Cloning into 'xx'...
remote: Counting objects: 105491, done.
remote: Compressing objects: 100% (32876/32876), done.
Receiving objects: 100% (105491/105491), 1.74 GiB | 19.55 MiB/s, done.
remote: Total 105491 (delta 67211), reused 104583 (delta 66603)
Resolving deltas: 100% (67211/67211), done.
Checking connectivity... done.
Checking out files: 100% (16545/16545), done.
查看更多
【Aperson】
4楼-- · 2020-05-25 07:25

If you are using windows and this error is happening in tortoise Git or Sourcetree try to generate your keys with puttYGen. Or create a new key from your existing private key with puttYGen (use the Load option) then save that private key with the extension ppk in a any folder. After that, add this key (with the extension ppk) in pageant (google to know how is the icon, it must appear in the right bottom corner next to hour) right click and add key. Try to be sure you setup your tortoise or your sourcetree to use this ppk key. Tortoise: Setting - Network - ssh client (must be TortoiseGitPLink.exe, if not is in the git tortoise git_home\bin folder) Source Tree: Tools - Options - SSh client Putty/PLink

查看更多
ゆ 、 Hurt°
5楼-- · 2020-05-25 07:27

Your problem is described in details here:

If the client and server are unable to agree on a mutual set of parameters then the connection will fail.
OpenSSH (7.0 and greater) will produce an error message like this:
Unable to negotiate with 127.0.0.1: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1


Setting alternate ssh keys

ssh-keygen -t rsa -C <your comment>

now add the public key under your server account and try again.

查看更多
ら.Afraid
6楼-- · 2020-05-25 07:30
Host     xxxx.yyyy.com 
KexAlgorithms +diffie-hellman-group1-sha1
Port     portNumber
User     userName-yourDomain-com

Include above lines in .config file and add .config file in .ssh directory where id_rsa.pub and other files are located.

查看更多
何必那么认真
7楼-- · 2020-05-25 07:36

This error occurs when the client and server are unable to agree on the key exchange algorithm to use. You can see in the error log what key exchange algorithms the server is offering to use. In case when your client is unable to work with the methods offered by the server, the error is thrown. To fix this issue changes can be made on the client or server side. If you can change the server's configuration, that would be the better path to take as you wouldn't have to make changes in all clients. To fix the issue on the server side, you need to upgrade/configure the server to not use deprecated algorithms.

If change on the server side is not possible, one could simply force the client to re-enable the key exchange algorithms the server is ready to work with. You can do this permanelty by updating the ~/.ssh/config file on linux or C:\Program Files\Git\etc\ssh\ssh_config file on windows and adding the following lines :

Host example.org # you can use the * wildcard character. e.g. *.example.org or simplly * for all hosts
User yourUserName # optional
KexAlgorithms +diffie-hellman-group1-sha1 # you can also specify multiple algorithms by separating them with comma e.g. diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
查看更多
登录 后发表回答