ssh 접속 시도시 아래와 같은 에러를 발생시키면서 접근이 불가능합니다.

$ ssh -i ./something.pem user@server.com

Unable to negotiate with server.com port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

원인은 MacOS를 Ventua 13.0로 업데이트하면서 발생되었습니다.
하지만 근본적인 원인은 ssh 접속에 cbc 알고리즘을 사용하였기 때문입니다. 아래 링크를 통해 cbc 알고리즘은 2008년 공격에 취약한 것으로 판명되었음을 확인할 수 있습니다. 

 

CERT Coordination Center

The Vulnerability Notes Database provides information about software vulnerabilities.

www.kb.cert.org

하지만 취약함에도 불구하고 지속된 호환성을 위해 지원을 중지하지 않고있었습니다. 이제는 SSH에서 해당 알고리즘 사용을 중단시키는 단계에 도달하게 되었습니다. 아래 링크 질문에 따르면 지원 중단은 이미 2014년부터 시작되었습니다. 따라서 MacOS를 업데이트하면서 cbc 알고리즘을 비롯해 공격에 취약한 알고리즘 사용을 기본적으로 비활성화한 것입니다. 

 

AES256-CBC vs AES256-CTR in SSH

I used AES256-CBC to SSH to a remote server. Recently, it stopped working with the following message: no matching cipher found: client aes256-cbc server aes128-ctr,aes256-ctr,arcfour256,arcfour,...

crypto.stackexchange.com

가급적 SSH 서버를 업데이트하라는 알림 메시지라고 생각하면 좋을 것 같습니다.

해결 방법은 아래와 같습니다.

 

1. /etc/ssh/ssh_config 파일 수정

$ vim /etc/ssh/ssh_config
  • 주석 제거
    • Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
    • MACs hmac-md5,hmac-sha1,umac-64@openssh.com
  • 마지막 라인에 값 추가
    • HostkeyAlgorithms ssh-dss,ssh-rsa
    • KexAlgorithms +diffie-hellman-group1-sha1

 

2. ~/.ssh/known_hosts 파일 삭제

위와같이 하고 접속시도시, 아래와 같은 오류 메시지가 발생한다면 ~/.ssh/known_hosts 파일을 삭제 후 접근을 시도하시면 됩니다.

$ ssh -i ./something.pem user@server.com

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the DSA key sent by the remote host is
SHA256:ARhT+XFrh1tWX123x+qxrNV/2Fuc01LQ5nfJm51aTTZ.
Please contact your system administrator.
Add correct host key in /Users/user/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/user/.ssh/known_hosts:1
Host key for ncon2.nhnsystem.com has changed and you have requested strict checking.
Host key verification failed.
$ rm ~/.ssh/known_hosts