克隆git存储库的问题

sf6xfgos  于 2023-05-12  发布在  Git
关注(0)|答案(9)|浏览(139)

我正在尝试克隆git仓库,但出现错误

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

我编辑了~/.ssh/config并添加了

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

但我还是得到了同样的错误。
另一个解决方案是使用命令ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 user@127.0.0.1 -p 2222,但我也得到了端口号22的连接拒绝。
我用的是windows机器。

wz1wpwve

wz1wpwve1#

touch ~/.ssh/config

附加我的ssh配置的人谁遇到同样的问题

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

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

如果遇到其他问题,请使用更大的postBuffer

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.
e4eetjau

e4eetjau2#

在文件***C:\Program Files\Git\etc\ssh\ssh_config***中添加以下内容对我有效:
KexAlgorithms +diffie-hellman-group1-sha1,diffie-hellman-group14-sha1

vsikbqxv

vsikbqxv3#

我使用的是windows,在我的情况下,git clone在Jenkins中失败(在系统用户下运行)。
添加

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

into**~/.ssh/config会使克隆与当前用户一样运行。
对于
其他用户**,OpenSSH不会拾取配置。我必须将上面的配置添加到全局配置文件中:**“C:\Program Files\Git\etc\ssh\ssh_config”**使其工作。
这发生在我更新git-for-windows客户端后,新的git禁用了一些旧的密钥交换方法。另一个解决方法是安装旧版本的git。例如:https://github.com/git-for-windows/git/releases/tag/v2.20.1.windows.1

7qhs6swi

7qhs6swi4#

您的问题在here中详细描述:
如果客户端和服务器无法就相互的参数集达成一致,则连接将失败。
OpenSSH(7.0及更高版本)将生成如下错误消息:
Unable to negotiate with 127.0.0.1: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

设置备用ssh密钥

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

现在在你的服务器帐户下添加公钥,然后再试一次。

nfeuvbwi

nfeuvbwi5#

Host     xxxx.yyyy.com 
KexAlgorithms +diffie-hellman-group1-sha1
Port     portNumber
User     userName-yourDomain-com

在.config文件中包含上述行,并在id_rsa.pub和其他文件所在的.ssh目录中添加.config文件。

brgchamk

brgchamk6#

当客户端和服务器无法就要使用的密钥交换算法达成一致时,会发生此错误。
您可以在错误日志中看到服务器提供使用的密钥交换算法。如果您的客户端无法使用服务器提供的方法,则会抛出错误。
要解决此问题,可以在客户端或服务器端进行更改。如果您可以更改服务器的配置,这将是更好的方法,因为您不必在所有客户端进行更改。要在服务器端修复此问题,您需要升级/配置服务器,使其不使用已弃用的算法。
如果在服务器端不可能进行更改,则可以简单地强制客户端重新启用服务器准备使用的密钥交换算法。您可以通过更新 linux 上的**~/.ssh/config文件或 windows 上的C:\Program Files\Git\etc\ssh\ssh_config**文件并添加以下行来实现此永久性:

Host example.org # you can use the * wildcard character. e.g. *.example.org or simplly * for all hosts
User yourUserName # optional
KeyAlgorithms +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
nkoocmlb

nkoocmlb7#

如果您正在使用VS 2019的Git更改并遇到相同的问题,您可以从客户端解决该问题以重新启用密钥交换算法。您可以通过更新Windows上的C:\Program Files(x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\etc\ssh文件并添加以下行来永久执行此操作:

KexAlgorithms +diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
y3bcpkx1

y3bcpkx18#

如果你使用的是windows,并且这个错误发生在turkey Git或Sourcetree中,尝试使用puttYGen生成你的密钥。或者使用puttYGen从现有私钥创建一个新密钥(使用Load选项),然后将该私钥与扩展名ppk一起保存在any文件夹中。之后,添加此键(扩展名为ppk)在选美(谷歌知道如何是图标,它必须出现在右下角旁边的小时)右键单击并添加键。尝试确保您设置您的乌龟或您的sourcetree使用此ppk键。Tortoise:Setting - Network - ssh client(必须是TortoiseGitPLink.exe,如果不在git tortoise git_home\bin文件夹中)源树:工具-选项- SSh客户端Putty/PLink

ruyhziif

ruyhziif9#

如果您生成的密钥无法读取,也会发生此错误。
在Git 2.39(2022年第4季度)中,要签名的代码路径学会了在无法从“ssh-keygen”读取时报告错误。
现在,您将看到一条明确的错误消息:

failed reading ssh signing data buffer from...

before getting to the point where“Unable to negotiate with ...“)
参见commit 36fb0d0(2022年10月4日),作者Phillip Wood ( phillipwood )
(由Junio C Hamano -- gitster --合并于commit 644195e,2022年10月11日)

ssh signing:无法读取签名时返回错误

签字人:菲利普·伍德
如果无法读取签名文件,我们将打印错误消息,但不向调用者返回错误。
实际上,如果ssh-keygen调用成功,文件似乎不太可能不可读。
unlink_or_warn()调用被移动到函数的末尾,以便我们总是尝试删除签名文件。
目前这不是绝对必要的,但它可以保护我们避免在将来尝试读取签名文件和在函数结束时进行清理之间添加任何额外的代码。
unlink_or_warn()仅在警告存在且无法删除时打印警告。

相关问题