sanguk.dev
작성완료
Mac/Linux ssh 접속 시 'no matching key' 문제

Mac/Linux ssh 접속 시 'no matching key' 문제

macOS High Sierra로 업그레이드 후 SSH 접속 시 'no matching key' 오류가 발생할 수 있다. 이를 해결하기 위해, /etc/ssh/ssh_config 파일에서 주석을 제거하고 HostkeyAlgorithms 및 KexAlgorithms를 추가하는 방법과, SSH 접속 시 일회용 옵션을 추가하는 방법이 있다.

MacOSLinuxSSH

증상

애플 macOS High Sierra 버전으로 업그레이드 후, 아래와 같은 에러가 나며 네트워크 스위치나 방화벽을 접속할 수 없다.

shell
Unable to negotiate with 192.168.1.1 port 22: no matching host key type found. Their offer: ssh-dss

Unable to negotiate with 192.168.1.2 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

해결

방법1 (반 영구적 방법)

  1. Vi와 같은 텍스트 에디터를 이용해 /etc/ssh 디렉토리에 있는 ssh_config 파일을 연다.
shell
sudo vi /etc/ssh/ssh_config
  1. 아래와 같이 라인을 찾아 맨 앞에 있는 # (주석) 을 제거한다.
plain
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
  1. 그리고 맨 아래에 아래와 같은 라인을 추가한다.
plain
HostkeyAlgorithms ssh-dss,ssh-rsa
KexAlgorithms +diffie-hellman-group1-sha1
  1. 저장하고 나간다. (ESC 누르고)
plain
:wq!

방법2 (일회용 방법)

접속할 때 옵션을 추가한다.

  • o HostKeyAlgorithms=+ssh-rsa
  • o PubkeyAcceptedAlgorithms=+ssh-rsa
shell
ssh myname@mysite.kr -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa