1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHubに突然つながらなくなったときの対処方

Last updated at Posted at 2024-09-26

これは何?

GitHubに突然つながらなくなった際に試したことを防備録として記載する

2024/12/05追記
Automatically unlock this key whenever I'm logged inにチェックを入れたせいだと思われる

前までは,Enter password to unlock the private keyというポップアップが出ていた。

sign_and_send_pubkey: signing failed for RSA "/home/acer/.ssh/id_rsa" from agent: agent refused operation
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.

前提

ssh接続でgithubにアクセスしている


やったこと

sshにつながるか

ssh -T git@github.com
Hi sigma! You've successfully authenticated, but GitHub does not provide shell access.

これが返ってくるはずだが,返ってこないならssh接続が失敗している。

gnome-keyringは動作しているか

ps -ef | grep gnome-keyring
/usr/bin/gnome-keyring-daemon --daemonize --login

動作してそう

~/.ssh/id_rsaの権限チェック

AWSのEC2インスタンスに接続する際には鍵の権限が600になっていないと怒られるので一応確認。

ls -l ~/.ssh/id_rsa

600になってそうなので問題なし

sshの秘密鍵の設定を確認する

seahorseで鍵の管理をしてそうなので起動してみる。

seahorse

sshの秘密鍵のパスワードを変更してみたが解決せず
他の項目も関係なさそう。


暫定対応

  1. 秘密鍵と公開鍵の再生成

    ssh-keygen -t rsa -C 鍵名
    
  2. GitHubに秘密鍵を再登録

  3. stack overflowにあるようにsshエージェントに秘密鍵を登録する

    ssh-add ~/.ssh/id_rsa
    

接続チェックしたら接続できました。

ssh -T git@github.com
Hi sigma! You've successfully authenticated, but GitHub does not provide shell access.

暫定対応時の問題点 2024/12/05追記

PCの電源を落としたりするとssh-addが切れてしまい,定期的にssh-addしないと同様のエラーが出るようになってしまった。

解決した方法

逆にssh-add -dしてみたらEnter password to unlock the private keyのポップアップが出てくるようになった気がする。

ssh-add -d ~/.ssh/id_rsa
1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?