본문 바로가기

DevOps

[EC2]SSH 접속 에러 조치 방법 : Host key verification failed (Mac)

기존 EC2 (On Demand)를 종료하고, 예약인스턴스 EC2를 새롭게 올리고 IP는 그대로 사용해서 서버를 구성했습니다.

근데, Windows Putty 접속은 잘되는데 MAC 에서 ssh 접속 하려니 아래와 같은 에러가 나옵니다.


@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@    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 ED25519 key sent by the remote host is

SHA256:v**************************

Please contact your system administrator.

Add correct host key in /Users/jason/.ssh/known_hosts to get rid of this message.

Offending ED25519 key in /Users/jason/.ssh/known_hosts:1

Host key for 13.***.***.*** has changed and you have requested strict checking.

Host key verification failed.


  • 원인
    • 서버가 교체 되었거나, IP가 변경이 되어서 발생한 것입니다.
    • 서버가 교체 되었을때  ( {$Home}/.ssh/ )에 'known_hosts' 라는 파일에 이전 서버 정보가 남아서 에러가 발생했습니다.
  • 해결법
    • vi 로 known_hosts 파일을 열어서, 해당 ip가 있는 라인을 삭제 후 재 접속 시도하고 연결 여부 물어보면 "yes" 하고 시도합니다.
  • 주의사항
    • known_hosts 파일을 삭제하면, key 파일을 다시 받아야하니 굳이 삭제 않습니다.