とある日,git push
しようとするとこんなエラー出た.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for [git.xxxxx.com]:XXXX has changed,
and the key for the corresponding IP address [XX.XX.XX.XXX]:XXXX
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:RGRZ/*********************************************.
Please contact your system administrator.
Add correct host key in /Users/XXXX/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/XXXX/.ssh/known_hosts:1
RSA host key for [git.xxxxx.com]:XXXX has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
エラー原因
~/.ssh/known_hosts
に記載されている接続先のサーバ情報と移行後のサーバの情報(今回の場合はIPアドレス)とが異なっているため.
こんな時にエラー出る
サーバの移行後にSFTPクライアントソフトやTerminalで接続をしようとする時.たとえ接続先やSSH認証鍵が合っていてもこのようなエラーが出る.
対処方法
エラーメッセージどおり,~/.ssh/known_hosts
の指定された行を削除します.
今回は一行目を削除しました.
どの行を削除すればわからない場合はrm ~/.ssh/known_hosts
でファイルごと削除しちゃって大丈夫です.ホストの再登録ができます.