SSH: DH_GEX 그룹이 범위를 벗어났습니다.

SSH: DH_GEX 그룹이 범위를 벗어났습니다.

우리는 최근 공급업체에서 제공한 OpenSSH용 패치를 적용했습니다. 이 패치는 최근 Logjam 공격에 대응하여 몇 가지 키 교환 프로토콜을 비활성화했습니다. 이 패치를 적용한 후 연결 협상이 실패하여(더 이상 사용되지 않는 키 교환 알고리즘으로 인해) SFTP를 통해 파일을 교환할 수 없는 공급업체가 몇 군데 있습니다.

공급업체와 이야기하기 전에 우리가 보고 있는 몇 가지 사항을 확인하고 싶습니다. 다음은 문제 공급업체 중 하나와의 샘플 SSH 세션입니다(줄 번호 추가됨).

# ssh -vv [email protected]
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: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],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,[email protected]
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,[email protected]
25 debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
26 debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
27 debug2: kex_parse_kexinit: none,[email protected],zlib
28 debug2: kex_parse_kexinit: none,[email protected],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,[email protected]
38 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-md5-96,hmac-sha1-96,hmac-sha256,[email protected]
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

최신 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/6069Mikrotik Routerboards에 대한 다음 수정 사항을 언급합니다.

/ip ssh set strong-crypto=yes

(비슷한 오류 메시지를 찾을 때 웹 검색에서도 이 답변이 나오므로 여기에 주목하세요.)

ssh_config를 편집하거나 SSH 서버를 업데이트하지 않고 Git을 통해 사용하려면 다음을 수행하세요.

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

답변2

이거 맞은 것 같은데벌레.

원인

Diffie-Hellman Group Exchange를 다루면서 openssh 패키지가 변경되었습니다. 이전에는 1024 - 8192 크기의 키를 교환할 수 있었습니다. 보안을 강화하고 "로그잼" 취약점을 방지하기 위해 최소값을 1536으로 높였습니다. 그러나 1024만 지원하는 일부 타사 SSH 구현과 함께 사용하면 오류가 발생합니다. 이상적으로는 더 큰 키 크기를 사용하도록 타사 SSH 구성 또는 코드를 업데이트해야 합니다.

...

링크에서 3가지 다른 해상도를 찾을 수 있습니다. 관리 권한이 없거나 더 깊은 변경을 수행하기에는 관료주의가 너무 많은 상황에서는 서버에서 SHA-2 가용성을 기다리는 동안 문제가 있는 알고리즘을 제거하는 것이 나에게 최선의 선택처럼 보였습니다. $HOME/.ssh/config 파일에서 사용자 기반 방식으로 이를 수행할 수도 있습니다.

KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

관련 정보