TK-NOTE

技術的なことや趣味、読んだ本についての感想などを投稿してきます。

git clone したらWARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!と怒られた

Cover Image for git clone したらWARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!と怒られた
coding

先日git cloneコマンドを実行時にWARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!のエラーになったので対処法を記載します。

事象

git cloneコマンドが実行できない

$ git clone git@github.com:xxx/xxx.git
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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:xxx.
Please contact your system administrator.
Add correct host key in /path/to/.ssh/known_hosts to get rid of this message.
Offending RSA key in /path/to/.ssh/known_hosts:11
RSA host key for github.com 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.


対処法

エラーメッセージにある通り、known_hostファイルのgithub.comの行を削除したらうまくいきました(行数まで教えてくれている!!)。

vim /path/to/.ssh/known_hosts


余談

githubのブログにも記事がありました。
https://github.blog/2023-03-23-we-updated-our-rsa-ssh-host-key/
このブログによると、GithubのRSA SSH秘密鍵が一時的に公開されてしまっており、3/24 5時ごろにRSA SSH鍵の切り替えを行なったことの影響のようです。
別件で、GithubActionが謎に落ちることがあって原因がわからずだったのですが、この件が関係していたのかもしれません。