SSH接続を行った際に、サーバー側がOSを再インストールしたり、ホスト名を付け替えたりすると、次のようなエラーが発生し、接続できない場合があります。
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00.
Please contact your system administrator.
Add correct host key in /home/hogehoge/.ssh/known_hosts to get rid of this message.
Offending key in /home/hogehoge/.ssh/known_hosts:3
RSA host key for remote_host has changed and you have requested strict checking.
Host key verification failed.
SSH接続とは
SSHでは、安全な接続を行うために接続先サーバーの情報(RSA公開鍵のフィンガープリント)を、クライアントは保存しています。
SSH接続時には、以前保存したこの情報と、これから接続しようとしているサーバーの情報が一致しているのかを確認することで、
ユーザー(クライアント)が知らない間に、別のサーバーへ接続されてしまうことを防ぐことができ、安全性を保つことが可能となります。
対処方法
Macのターミナル上で以下のコマンドを実行し、ホスト鍵の情報を削除します。その後、再度SSH接続を行うことで解決します。
$ rm ~/.ssh/known_hosts