🔲

GithubにpushしたらPermission deniedが出て解消した話

に公開
$ git push origin feature/aaa

Enter passphrase for key '/c/Users/hoge/.ssh/id_ed25519_fuga':
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.

何もしてないのにコワレマシタ (´・ω・`)

先週末は問題なかったので、週明けびっくり状態。

会社でSSOの認証があるので、その辺が変わったかな?と思ったけど、自分のアカウントページの鍵のところを見ても問題ない。

また、別の鍵は普通に動いていて自分のアカウントが組織から外されたり変更された線もなさそう。

AIに聞いてみたら強制的にSSO認証セッションを更新してみては?とのこと。

ssh -vT git@github.com

ぐぬぬ。うまくいかず。

でもよく見ると、あるある系の名前の鍵だけ試して、終わっているログが出ている。

debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Will attempt key: /c/Users/hoge/.ssh/id_rsa
debug1: Will attempt key: /c/Users/hoge/.ssh/id_ecdsa
debug1: Will attempt key: /c/Users/hoge/.ssh/id_ecdsa_sk
debug1: Will attempt key: /c/Users/hoge/.ssh/id_ed25519
debug1: Will attempt key: /c/Users/hoge/.ssh/id_ed25519_sk
debug1: Will attempt key: /c/Users/hoge/.ssh/id_xmss
...中略
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).

自分は鍵名称変えているので、鍵名指定して再度トライ。

# SSO認証セッションを強制更新
ssh -i ~/.ssh/id_ed25519_fuga -vT git@github.com  # 接続テスト実行

ビンゴ!!やったぜ!!

同じようなエラーが出た方はお試しあれ。

Discussion