SSH – ssh no matching key exchange method found 원인과 해결 방법

ssh no matching key exchange method found 오류는 SSH 클라이언트와 서버가 서로 지원하는 **키 교환 알고리즘(KEX)**이 일치하지 않을 때 발생한다. 특히 OpenSSH 최신 버전구형 SSH 서버 간의 연결에서 자주 발생한다.

오류 메시지 이해

$ ssh root@192.168.0.100
Unable to negotiate with 192.168.0.100 port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,kex-strict-s-v00@openssh.com

클라이언트는 diffie-hellman-group1-sha1 알고리즘을 허용하지 않고, 서버는 이 알고리즘만 제공하면서 협상(negotiation)에 실패했다는 내용이다.

원인 분석 – KexAlgorithms란?

Key Exchange Algorithms(KEX)은 SSH 연결 시 사용되는 암호화 방식 중 하나이다.

클라이언트(예: OpenSSH 8.0+)는 다음을 지원할 수 있다:

$ ssh -Q kex
diffie-hellman-group1-sha1
diffie-hellman-group14-sha1
diffie-hellman-group14-sha256
diffie-hellman-group16-sha512
diffie-hellman-group18-sha512
diffie-hellman-group-exchange-sha1
diffie-hellman-group-exchange-sha256
ecdh-sha2-nistp256
ecdh-sha2-nistp384
ecdh-sha2-nistp521
curve25519-sha256
curve25519-sha256@libssh.org
sntrup761x25519-sha512@openssh.com

반면, 구형 서버는 다음만 지원할 수 있다:

diffie-hellman-group1-sha1

이 알고리즘은 보안 취약점(CVE-2002-2001 등)으로 인해 신버전 OpenSSH에서 기본적으로 비활성화됐다.

해결 방법

일회성으로 KEX 알고리즘 강제 지정

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 user@192.168.0.100

예제:

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -oHostKeyAlgorithms=+ssh-rsa root@192.168.0.100

(Client) SSH config에 서버별 설정 추가

~/.ssh/config 파일에 다음 내용 추가:

Host old-server
HostName 192.168.0.100
User root
KexAlgorithms +diffie-hellman-group1-sha1,
diffie-hellman-group-exchange-sha1

(Server) sshd_config 수정

Client가 dropbear등을 사용하여 대응을 할 수 없다면 서버쪽에서 /etc/ssh/sshd_config에 다음 설정 추가한다.

KexAlgorithms +diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1
sudo systemctl restart sshd

보안상 권장되지 않으며, 신뢰된 내부망을 사용하는 경우에만 적용하는 것이 좋다.

Dropbear 환경의 추가 이슈

Dropbear는 임베디드 환경에서 많이 사용되는 SSH 서버이다.

Dropbear에서 제공하는 KEX 확인 방법

Dropbear는 일반적인 OpenSSH보다 제한된 KEX만 제공한다.

  • Dropbear 2015 이전: group1만 제공
  • Dropbear 최신 버전(2020+) : group14 등 지원 추가됨

해결 방법

  • 클라이언트에서 KexAlgorithms 허용
  • 가능하면 Dropbear를 업데이트
  • 또는 OpenSSH 서버 패키지로 교체

답글 남기기