rohaniのブログ

ゆるっと自然言語処理奴。ときどき工作系バイト。

SSH接続時のWARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

ラズパイのOSをSDカードにクリーンインストールして再立ち上げし、同じIPアドレスで再接続しようとすると、このようなwarningが表れた。

$ ssh pi@192.168.xx.xx
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ECDSA key sent by the remote host is
xxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Please contact your system administrator.
Add correct host key in /Users/username/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/username/.ssh/known_hosts:x
ECDSA host key for 192.168.xx.xx has changed and you have requested strict checking.
Host key verification failed.

このIPアドレスへ接続する際のECDSA host keyが違っているよ!という警告である。

身に覚えがないのに警告された場合は警戒しなければならないが、今回は心当たりがあるので以下の対処を行った。

$ ssh-keygen -R 192.168.xx.xx

こうすると、「このIPアドレスへ接続する際のECDSA host key」の履歴が消えるので、初めて接続するのと同じ状態になり、警告が出なくなる。