0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

突然Gitのリモートリポジトリにアクセスできなくなった

Posted at

GitHubのリモートリポジトリに、突然アクセスできなくなった。
git push origingit fetch originなどすると、以下のエラーが出る。

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

2時間ほど前には問題なくアクセスできていたのに。
その時と同じマシンを使っている、しかもシャットダウンもしてないのに。(一時スリープ状態にはなっていた)

原因はSSHエージェント

ChatGPTに聞いていろいろ試したところ、「SSHエージェントの起動」で解決した。

eval "$(ssh-agent -s)"

SSHエージェントが勝手に死んでいるというのは、スリープ復帰時などに発生することがあるらしい。

ChatGPTは、SSHエージェントを自動起動させる方法など、この問題に遭遇しないような対策も提示してくれたのだけど、
通常は発生しないようなことに対処するスクリプトをわざわざ書いておくというのは間違っている気がしたので、
問題が発生したときに都度対処することにした。(コマンド一行実行するだけだし)

次に問題が発生したときに、思い出せるようにここに書き留めておく。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?