Raspberry PiにOSの入れ替えなどでmicroSDを入れ替えてSSHを行うと以下のようなエラーが出てきます。
$ ssh pi@raspberrypi.local
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for raspberrypi.local has changed,
and the key for the corresponding IP address fe80::1faa:a2e8:7009:f905%en3
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
SHA256:CLOCUxmxK166ZS8VLPofZmtfZxCD8VLC8O2Uc3v+9As.
Please contact your system administrator.
Add correct host key in /Users/user/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/user/.ssh/known_hosts:4
ECDSA host key for raspberrypi.local has changed and you have requested strict checking.
Host key verification failed.
「前に接続したときとSSH接続キーが変わってるから使えないよ!」ってことみたいです。
これに対処するには以前に使っていたSSH接続キーを初期化してしまえばOK!
ターミナルで以下を打ち込んでください。
ssh-keygen -R raspberrypi.local
最後の「raspberrypi.local」の部分がホスト名に対応しています。
つまり、ホスト名が同じ接続先だけどOS入れ替えなどで、前と同じSSH接続キーが使えなくなったときに出てきます。
毎回ホスト名が同じにならないように変えてしまえば回避できます。
話をもとに戻します。
再度SSH接続を試みると接続続行していい?と聞かれますのでyesで接続できます。
Are you sure you want to continue connecting (yes/no)? yes
pi@raspberrypi:~ $
以上です。