はじめに
今回リモートへプッシュやプルをしようとした際、【REMOTE HOST IDENTIFICATION HAS CHANGED!】とエラーが表示されました。
これはリモート側のキーが変わることで起こるエラーですが、Githubやその他クライアントでも同じことが起こりえます。
どのクライアントでも基本的に同じ対応でいけると思いますが、今回は上記エラーの対処法を備忘録的にまとめておこうと思います。
エラーの対処法
まず、表示されるエラーは以下のような構文です。
Pushing to bitbucket.org:XXXX.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:XXXXXXXXX.
Please contact your system administrator.
Add correct host key in XXXX.ssh/known_hosts to get rid of this message.
Offending RSA key in XXXX.ssh/known_hosts:3
Host key for bitbucket.org 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.
翻訳すると半ば脅しのようなエラーになっていますが、、、
原因はシンプルで冒頭でご説明した通り、リモート側のhost keyが変わったことによるエラーのようです。
上記が原因なので、対処法としては現状のKeyを新しいものに置き換える必要があります。
キーの置き換えは以下を実行することで対応可能です。
ssh-keygen -R bitbucket.org && curl https://bitbucket.org/site/ssh >> ~/.ssh/known_hosts
対応としては以上になります。
さいごに
対応方法がわかっていたとしてもこの手のエラーは一瞬ドキっとしますよね、、、