1
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?

More than 3 years have passed since last update.

git@github.com: Permission denied (publickey). の解決方法

Last updated at Posted at 2021-02-23

git pushしようとしたら以下のエラーが発生しました

エラーメッセージ

$ git push
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接続できるか試してみる
$ ssh -T git@github.com
git@github.com: Permission denied (publickey).

解決方法

ssh-addコマンドで状況を確認してみます

$ ssh-add -l
The agent has no identities.

エージェントにIDが登録されていないようです。
今回はこれが原因なのでIDを登録します。

$ ssh-add ~/.ssh/id_25519
Identity added: /Users/<username>/.ssh/id_25519 (47884591+yoritin@users.noreply.github.com)

再度確認

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

ssh接続が確認できるようになりました。

ちなみに、再起動するたびに毎回エラーが発生する場合は
ssh-add するときに -K オプションを付けると再起動のたびにssh-addする手間が省けます。

1
0
1

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