8
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Git】WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!の対処方法

Last updated at Posted at 2020-10-26

とある日,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でファイルごと削除しちゃって大丈夫です.ホストの再登録ができます.

8
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?