DH GEX集团超出范围

我正在通过SSH连接到我的服务器:

ssh -v --@-- OpenSSH_7.2p2 Ubuntu-4ubuntu1, OpenSSL 1.0.2g-fips 1 Mar 2016 debug1: Reading configuration data /home/paul/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to -- [--] port 22. debug1: Connection established. debug1: identity file /home/paul/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/paul/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/paul/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/paul/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/paul/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/paul/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/paul/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/paul/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu1 debug1: Remote protocol version 1.99, remote software version OpenSSH_6.6.1p1 debug1: match: OpenSSH_6.6.1p1 pat OpenSSH_6.6.1* compat 0x04000000 debug1: Authenticating to --:22 as 'root' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: diffie-hellman-group-exchange-sha1 debug1: kex: host key algorithm: ssh-rsa debug1: kex: server->client cipher: aes128-cbc MAC: hmac-sha1 compression: none debug1: kex: client->server cipher: aes128-cbc MAC: hmac-sha1 compression: none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<7680<8192) sent debug1: got SSH2_MSG_KEX_DH_GEX_GROUP ssh_dispatch_run_fatal: Connection to -- port 22: DH GEX group out of range 

我读过这个问题SSH:DH_GEX组广泛地超出范围,但它似乎并没有回答这个问题。 我控制客户端和服务器,他们都使用普通的OpenSSH和Ubuntu Linux。 没有第三方。 错误似乎有点不同,它不是抱怨比特大小。

看起来你正在运行一个较新的 OpenSSH客户端(OpenSSH 7.2p2)针对较旧的 OpenSSH服务器(OpenSSH 6.6.1p1)。 在OpenSSH 7.1p2发行说明中 ,它提到:

  • ssh(1),sshd(8):将diffie-hellman-group-exchange所支持的最小模数大小增加到2048位。

从报告的错误消息看来,它是您的客户端拒绝由_server提供的DH组交换值。

因此,我想知道这个“突然的问题”是否在客户端机器应用了一些软件包/更新的时候开始发生。

根据这个描述了非常类似问题的SecurityExchange文章 ,“解决scheme”可能是: a)修改服务器端的/etc/ssh/moduli文件,使得服务器不使用小于2048位的DH组, b)将服务器升级到OpenSSH 7.1p2或更高版本。

如果您想使用较新的OpenSSH连接到已弃用的服务器:

 ssh -o KexAlgorithms=diffie-hellman-group14-sha1 -o HostKeyAlgorithms=+ssh-dss my.host.com 

如果你想看看发生了什么,添加-v,如果它仍然不起作用,则使用-o HostKeyAlgorithms = ssh-dss:

 ssh -v -o HostKeyAlgorithms=ssh-dss -o KexAlgorithms=diffie-hellman-group14-sha1 my.host.com 

当然,您也可以编辑/ etc / ssh / ssh_config或〜/ .ssh / ssh_config,并添加:

 Host my.host.com *.myinsecure.net 192.168.1.* 192.168.2.* HostKeyAlgorithms ssh-dss KexAlgorithms diffie-hellman-group1-sha1 

https://forum.ctwug.za.net/t/fyi-openssh-to-access-rbs-openssh-7/6069提到Mikrotik路由器板上的以下修复&#xFF1A;

 /ip ssh set strong-crypto=yes 

(注意这里,因为这个答案也出现在网页search时,寻找类似的错误信息。)

如果你想通过Git使用它,而不编辑你的ssh_config或更新SSH服务器:

 GIT_SSH="ssh -oHostKeyAlgorithms=+ssh-dss -oKexAlgorithms=diffie-hellman-group14-sha1" git clone ssh://user@host/path-to-repository