SSH:DH_GEX组超出范围


18

我们最近为OpenSSH应用了供应商提供的补丁。该补丁禁用了一些密钥交换协议,以响应最近的Logjam攻击。应用此修补程序后,由于连接协商失败(可能由于密钥交换算法已弃用),我们有一些供应商无法通过sftp交换文件。

在与供应商交谈之前,我想验证一下我们所看到的几件事。这是与问题供应商之一(添加行号)的示例SSH会话:

# ssh -vv user@host.domain.com
01 OpenSSH_6.2p2, OpenSSL 0.9.8j-fips 07 Jan 2009
02 debug1: Reading configuration data /etc/ssh/ssh_config
03 debug1: /etc/ssh/ssh_config line 20: Applying options for *
04 debug2: ssh_connect: needpriv 0
05 debug1: Connecting to host.domain.com [1.2.3.4] port 22.
06 debug1: Connection established.
07 debug1: permanently_set_uid: 0/0
08 debug1: identity file /root/.ssh/id_rsa type -1
09 debug1: identity file /root/.ssh/id_rsa-cert type -1
10 debug1: identity file /root/.ssh/id_dsa type -1
11 debug1: identity file /root/.ssh/id_dsa-cert type -1
12 debug1: identity file /root/.ssh/id_ecdsa type -1
13 debug1: identity file /root/.ssh/id_ecdsa-cert type -1
14 debug1: Enabling compatibility mode for protocol 2.0
15 debug1: Local version string SSH-2.0-OpenSSH_6.2
16 debug1: Remote protocol version 2.0, remote software version GXSSSHD_Comments
17 debug1: no match: GXSSSHD_Comments
18 debug2: fd 3 setting O_NONBLOCK
19 debug1: SSH2_MSG_KEXINIT sent
20 debug1: SSH2_MSG_KEXINIT received
21 debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
22 debug2: kex_parse_kexinit: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,ssh-dss
23 debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
24 debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
25 debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
26 debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
27 debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
28 debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
29 debug2: kex_parse_kexinit:
30 debug2: kex_parse_kexinit:
31 debug2: kex_parse_kexinit: first_kex_follows 0
32 debug2: kex_parse_kexinit: reserved 0
33 debug2: kex_parse_kexinit: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256
34 debug2: kex_parse_kexinit: ssh-dss,ssh-rsa
35 debug2: kex_parse_kexinit: aes128-cbc,3des-ctr,aes128-ctr,3des-cbc,blowfish-cbc,arcfour,arcfour128
36 debug2: kex_parse_kexinit: aes128-cbc,3des-ctr,aes128-ctr,3des-cbc,blowfish-cbc,arcfour,arcfour128
37 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-md5-96,hmac-sha1-96,hmac-sha256,hmac-sha256@ssh.com
38 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-md5-96,hmac-sha1-96,hmac-sha256,hmac-sha256@ssh.com
39 debug2: kex_parse_kexinit: none,zlib
40 debug2: kex_parse_kexinit: none,zlib
41 debug2: kex_parse_kexinit:
42 debug2: kex_parse_kexinit:
43 debug2: kex_parse_kexinit: first_kex_follows 0
44 debug2: kex_parse_kexinit: reserved 0
45 debug2: mac_setup: found hmac-md5
46 debug1: kex: server->client aes128-ctr hmac-md5 none
47 debug2: mac_setup: found hmac-md5
48 debug1: kex: client->server aes128-ctr hmac-md5 none
49 debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1536<3072<8192) sent
50 debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
51 DH_GEX group out of range: 1536 !< 1024 !< 8192`

因此,在密钥交换协商期间,客户端和服务器交换其受支持算法的列表(第21和33行)。他们同意使用在这两个列表中找到的第一个匹配项diffie-hellman-group-exchange-sha1。据我了解,该算法支持客户端和服务器随后必须协商的一定范围的位长。在正常情况下,客户端和服务器会协商一个位长,并使用文件中的DH主键交换密钥moduli,例如/etc/ssh/moduli(我知道这最后一条语句 “门外汉”,但这大约是长短之短)。它)。

在这种情况下,我认为我看到的是位长协商失败。在第49行,客户(我)说:“我支持1536至8192之间的位长,并希望使用3072位。” 但是,服务器回复并说“我仅支持1024位”。此时客户放弃并说“我不能和你说话”。这是对这里发生的事情的合理描述吗?

据我了解,此刻问题完全在服务器端(假设我们没有协商较弱的算法diffie-hellman-group1-sha1)。在密钥交换过程中,必须修改服务器以支持更大的位长。

我想确保我在继续之前正确理解了这一点。输入表示赞赏。


1
您没看错。另一端到底是什么?看起来不像任何普通的ssh服务器。
迈克尔·汉普顿

不知道服务器是什么。我们在两家不同的供应商(银行都是供应商)中遇到相同的问题。这两个服务器都不会在会话中标识自己(这不足为奇)。
2015年

您可能以为银行在安全性上会更多一些,但是a ...
Michael Hampton

2
搜索“ GXSSSHD_Comments”会在各种SFTP客户端论坛中显示评论,这反过来似乎表明您的服务器是GXS MFT应用程序-非常精进。
Castaglia '16

Answers:


21

如果要使用较新的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路由器板上的以下修复程序:

/ip ssh set strong-crypto=yes

(在此注意这一点,因为当寻找类似的错误消息时,此答案也会出现在网络搜索中。)

如果要通过Git使用它而不编辑ssh_config或更新SSH服务器,请执行以下操作:

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

2
这也适用于sftp
bao7uo 2016年

11

看来您遇到了这个错误

原因

已对处理Diffie-Hellman Group Exchange的openssh软件包进行了更改。以前,大小为1024-8192的密钥可以交换。为了提高安全性并避免了“ logjam”漏洞,最小值已提高到1536。但是,如果与仅支持1024的某些第三方ssh实现一起使用,则会发生故障。理想情况下,应更新第三方ssh配置或代码以使用更大的密钥。

...

您可以在链接中找到3种不同的分辨率。在您没有管理员权限或官僚机构太多而无法进行更深层次更改的情况下,在我等待服务器中的SHA-2可用性时摆脱有问题的算法似乎是我的最佳选择。您甚至可以在$ HOME / .ssh / config文件中以基于用户的方式执行该操作。

KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.