【问题标题】:Using "KexAlgorithms diffie-hellman-group1-sha1" did not resolve "no matching key exchange method found" error使用“KexAlgorithms diffie-hellman-group1-sha1”没有解决“找不到匹配的密钥交换方法”错误
【发布时间】:2016-12-10 17:53:58
【问题描述】:

关于以下错误有很多问题,但他们都有相同的解决方案,但没有任何效果:

$ git push
Unable to negotiate with 192.168.XXX.XXX: 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.

有一个 article on openssh.com 没有帮助。特别是有人建议:

...在 ~/.ssh/config 文件中:

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

我就是这么做的。我假设 ~ 在 Windows 上解析为 %userprofile%。我的文件在C:\Users\MY_USERNAME\.ssh\config:

## use kex algorithm ##
Host 192.168.XXX.XXX
KexAlgorithms diffie-hellman-group1-sha1

结果是什么都没有改变。还有人建议使用ssh -o,但我还没有找到一个答案来描述你是如何做到这一点的。我试过这个:

$ ssh -oKexAlgorithms=+diffie-hellman-group1-sha1
usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]

我需要连接到那个 GIT 存储库。我在窗户上。存储库使用 Gerrit。我也使用 SourceTree,它推入存储库没有问题。所以存储库可以工作,但是我的 bash 中的 git 或 openSSH 坏了。

我做错了什么,这个解决方案对我不起作用?

【问题讨论】:

  • 尝试使用“-vv”标志运行 ssh。它将打印它读取的配置文件的名称,并打印密钥交换的详细信息。
  • 你说你在配置文件中做了同样的事情,但是你的配置文件没有显示你做了。你有KexAlgorithms diffie-hellman-group1-sha1,但需要KexAlgorithms +diffie-hellman-group1-sha1。注意diffie之前的+
  • @BrianPursley Hah,5 年后我终于知道我做错了什么以及为什么我的答案中的命令有效。

标签: windows git ssh


【解决方案1】:

使用我在一些评论线程中随机找到的这个命令解决:

export GIT_SSH_COMMAND='ssh -o KexAlgorithms=+diffie-hellman-group1-sha1'

每次打开 Git Bash 时都必须调用。是的,git 是地狱。

【讨论】:

    【解决方案2】:

    我通过将我的 Open SSH 版本更新到最新版本 (7.5p1-1) 解决了 Windows 10 上的类似问题,然后确保 C:Program Files\OpenSSH\bin 是系统路径中的第一个条目,因此它使用那个 ssh.exe 而不是其他的。

    【讨论】:

      【解决方案3】:

      在将“git for windows”更新到版本 2.25.1 后,我开始收到此错误 This algo was deprecated by GitHub in Feb. of 2018.

      @Kenster 对“使用 ssh -vv ...”的评论来查看您的配置文件所在的位置是关键。 我在 Windows 中的主驱动器是网络驱动器,因此我的默认 .ssh 文件夹位于该网络卷上。

      将名为“config”的文件添加到该文件夹​​:

      Host 127.0.0.1
      Port 2222
      KexAlgorithms +diffie-hellman-group1-sha1
      

      允许我再次连接到我的流浪环境。

      【讨论】:

        【解决方案4】:

        我也遇到了同样的问题。请安装旧版本的“Git for Windows”。 https://github.com/git-for-windows/git/releases/tag/v2.17.1.windows.1 此版本将解决您的问题。

        【讨论】:

          【解决方案5】:

          我在使用 Git for Windows 2.27.0 时遇到了同样的问题。

          Git for Windows 带来了自己的 OpenSSH 实现。我不得不更改配置文件 C:\Program Files\Git\etc\ssh_config

          Host myhost@example.com
              Port 22
              KexAlgorithms +diffie-hellman-group1-sha1
              KexAlgorithms +diffie-hellman-group14-sha1
          
          

          【讨论】:

            猜你喜欢
            • 2012-03-14
            • 1970-01-01
            • 2012-09-07
            • 1970-01-01
            • 1970-01-01
            • 2018-06-10
            • 2023-03-19
            • 1970-01-01
            相关资源
            最近更新 更多