【解決】ホストキーの確認に失敗しました(Host key verification failed.) sshログイン失敗

投稿者: | 2019-08-04

sshでログインしようとしたところ、

ssh -i id_rsa ユーザ名@ホスト名

以下のようなエラーが出て、ログインできない事象が発生しました。

Warning: Identity file id_rsa not accessible: No such file or directory.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for xxxxx.xxx has changed,
and the key for the corresponding IP address xxx.xxx.xxx.xxx
is unchanged. 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.
Offending key for IP in /Users/aoiyuki/.ssh/known_hosts:13
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Please contact your system administrator.
Add correct host key in /Users/aoiyuki/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/aoiyuki/.ssh/known_hosts:5
RSA host key for xxxxx.xxx has changed and you have requested strict checking.
Host key verification failed.

ネットで調べてみたところ、クライント側で以前の情報を記録しているのが原因のようです。

・参考
SSH接続エラー回避方法:.ssh/known_hostsから特定のホストを削除する/削除しないで対処する3つの方法 – Qiita
http://qiita.com/grgrjnjn/items/8ca33b64ea0406e12938

今回は上記サイトを参考に、削除する方法をやってみたところ解決しました。

実際に以下のコマンドです。

ssh-keygen -R ホスト名

問題なくログインできました(*´ω`*)