![見出し画像](https://assets.st-note.com/production/uploads/images/115980937/rectangle_large_type_2_d5caeb7d1c924eb87e0fcd8195dab8ac.jpeg?width=1200)
GitHub に SSH 接続したら繋がらなくなった件
先日、お客様先で GitHub に移行しました。
そしたら繋がらない事象にハマったので、メモを残します。
環境
GitHub
TortoiseGit
とりあえず fetch したら
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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:ここには SHA256 が!
Please contact your system administrator.
Add correct host key in ./.ssh/known_hosts to get rid of this message.
Offending RSA key in ./.ssh/known_hosts:1
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.
gitは正常に終了しませんでした (終了コード 128) (625 ms @ 2023/mm/dd H:i:s)
こんな呪いみたいなメッセージが出てきた。
長いし英語苦手だし、読むのめんどくさいんですけど、読まないと先に進めないので仕方ない。頑張って読みます。
ほぼ答えなんですけど、ここに問題っぽいところが書いてあります。
Add correct host key in ./.ssh/known_hosts to get rid of this message.
Offending RSA key in ./.ssh/known_hosts:1
Host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.
そういや GitHub がセキュリティ対策で SSH ホストキーを変更した記事がありました。
対応方法
じゃあこれに対応してやれば直るんじゃね?
ということで、下記のコマンドを投入。
$ ssh-keygen -R github.com
下記メッセージが出てきて、SSH ホストキーがアップデートされました。
# Host github.com found: line 1
./.ssh/known_hosts updated.
Original contents retained as ./.ssh/known_hosts.old
結果
ローカル環境の都合で config の変更もしないといけなかったですけど、この件だけで言えばこれで解決できました。
GitHub に SSH で接続して、こんな応答が返ってくれば成功です。
$ ssh -T git@github.com
Enter passphrase for key '.\id_rsa': "ここではパスフレーズを入力します"
Hi CLOWN! You've successfully authenticated, but GitHub does not provide shell access.
GitHub が SSH ホストキーを変更して以降、何もしていないひとは、この記事を参考にしてもらえればうれしいです。
支援のお願い
フォローなど
clown のフォロー
clown へのサポート
clown の書いた記事購入
いただけると励みになって頑張れます。
Amazon 欲しい物リスト
いただけると頑張れます。頑張ります。