物理のバス停 by salt22g

とある物理学見習いの備忘録。

sshで急にサーバーに繋げなくなったとき

サーバーがメンテナンス等を終えたあと再びsshで接続しようとするとこんなエラーにでくわすことがあります。

% ssh hogehoge
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for hogehoge has changed,
and the key for the corresponding IP address hogehoge
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 RSA key sent by the remote host is
SHA256:hogehogehogehogehogehogehogehogehogehoge.
Please contact your system administrator.
Add correct host key in /Users/hoge/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/hoge/.ssh/known_hosts:7
RSA host key for hogehoge has changed and you have requested strict checking.
Host key verification failed.
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
"誰かが厄介なことをしてるかもな!"
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
"誰かが盗聴してるかもな!(超意訳)"

かなりビビりますが、注目するのはこの部分。

Offending RSA key in /Users/hoge/.ssh/known_hosts:7

ホームディレクトリ以下にある隠しファイル.ssh/known_hostsを開いて該当の行を削除。
するとsshで接続できるようになりました。
めでたしめでたし。