如何在 Debian 8.0 上启用 diffie-hellman-group1-sha1 密钥交换?

j1*_*om. 162 ssh debian openssh key-authentication ssh-agent

我无法通过 ssh 连接到要求diffie-hellman-group1-sha1密钥交换方法的服务器:

ssh 123.123.123.123
Unable to negotiate with 123.123.123.123 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
Run Code Online (Sandbox Code Playgroud)

如何diffie-hellman-group1-sha1在 Debian 8.0 上启用密钥交换方法?

我曾尝试(如建议在这里),以

  1. 将以下行添加到我的 /etc/ssh/ssh_config

    KexAlgorithms diffie-hellman-group1-sha1,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
    Ciphers 3des-cbc,blowfish-cbc,aes128-cbc,aes128-ctr,aes256-ctr
    
    Run Code Online (Sandbox Code Playgroud)
  2. 重新生成密钥

    ssh-keygen -A
    
    Run Code Online (Sandbox Code Playgroud)
  3. 重新启动 ssh

    service ssh restart
    
    Run Code Online (Sandbox Code Playgroud)

    但仍然得到错误。

Ste*_*itt 275

OpenSSH 网站有一个页面专门讨论诸如此类的遗留问题。它建议在客户端采用以下方法:

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 123.123.123.123
Run Code Online (Sandbox Code Playgroud)

或更永久地,添加

Host 123.123.123.123
    KexAlgorithms +diffie-hellman-group1-sha1
Run Code Online (Sandbox Code Playgroud)

~/.ssh/config

这将启用客户端上的旧算法,允许它连接到服务器。

  • 确认这是一个不同的问题。我能够通过将以下条目添加到我的 `~/.ssh/config` 文件中来解决它。`Host 192.168.1.123` 及其下的 `Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc`。 (10认同)
  • 上面尝试过,但得到`无法与 192.168.1.123 端口 22222 协商:找不到匹配的密码。他们的报价:aes128-cbc,3des-cbc,aes256-cbc,twofish256-cbc,twofish-cbc,twofish128-cbc,blowfish-cbc` (4认同)

小智 39

我尝试了这个解决方案,但我的问题是我有很多(旧)客户端连接到我最近升级的服务器(ubuntu 14 -> ubuntu 16)。

openssh6 -> openssh7 的更改默认禁用了diffie-hellman-group1-sha1密钥交换方法。

阅读完这篇这篇后,我想出了我需要对/etc/ssh/sshd_config文件做的更改:

#Legacy changes
KexAlgorithms +diffie-hellman-group1-sha1
Ciphers +aes128-cbc
Run Code Online (Sandbox Code Playgroud)

但是更广泛的遗留更改集是(取自此处

#Legacy changes
KexAlgorithms diffie-hellman-group1-sha1,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
Ciphers 3des-cbc,blowfish-cbc,aes128-cbc,aes128-ctr,aes256-ctr
Run Code Online (Sandbox Code Playgroud)

  • 希望您能够在某个时候升级您的客户端,旧算法出于非常好的原因被禁用,不应轻易重新启用(您可能意识到这一点,我只是认为值得向其他读者指出)。 (8认同)
  • 这适用于服务器端(与非常相似的、已接受的侧重于客户端的答案不同。) (3认同)
  • 对于许多“内部”服务器(整个网络被锁定到受信任的用户)来说 diffie-hellman 就足够了。禁用它会无缘无故地破坏许多遗留工具,需要昂贵的开发工作来修改多年来无人关注的遗留代码。因此,拥有一种在服务器端启用它的方法仍然很有价值。 (3认同)

小智 10

我也面临同样的问题,但通过执行以下命令解决了它。您无需重新启动 SSH 服务器即可完成此操作 -

问题:

ssh test@123.123.123.123
protocol identification string lack carriage return
Unable to negotiate with 123.123.123.123 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
root@shoesdekho#
Run Code Online (Sandbox Code Playgroud)

解决方案:

ssh -o KexAlgorithms=diffie-hellman-group1-sha1 test@123.123.123.123
Run Code Online (Sandbox Code Playgroud)

在其他系统上,我观察到使用上述命令也不起作用。尝试使用命令添加密码。查看完整命令如下 -

root@shoesdekho#ssh -o KexAlgorithms=diffie-hellman-group1-sha1 -o Ciphers=aes256-cbc test@123.123.123.123                    
protocol identification string lack carriage return
Warning: Permanently added '123.123.123.123' (RSA) to the list of known hosts.
Password:


This computer system is restricted to authorized users.
 Unauthorized access attempts will be prosecuted.
 If unauthorized, disconnect now.

bookmiday#
Run Code Online (Sandbox Code Playgroud)


小智 5

问题01:

\n

\xe2\x80\x9c无法与 xxxx 端口 22 协商:未找到匹配的密钥交换方法。他们的报价:diffie-hellman-group1-sha1,diffie-hellman-group14-sha1\xe2\x80\x9d

\n

解决方案01:

\n

vim ~/.ssh/config 并添加:

\n
Host *\n    KexAlgorithms +diffie-hellman-group1-sha1,diffie-hellman-group14-sha1\n
Run Code Online (Sandbox Code Playgroud)\n

问题02:

\n

\xe2\x80\x9c 未找到匹配的主机密钥类型。他们的报价: ssh-rsa\xe2\x80\x9d

\n

解决方案02:

\n

vim ~/.ssh/config 并添加:

\n
Host * \n    PubkeyAcceptedAlgorithms +ssh-rsa \n    HostKeyAlgorithms +ssh-rsa \n
Run Code Online (Sandbox Code Playgroud)\n