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?

【GitHub】git@github.com: Permission denied (publickey).エラーになる

Last updated at Posted at 2025-11-18

はじめに

いつも使用しているPCとは違うPCでGitを使う必要があり、
GitHubの認証を追加しようとしたところ表題のエラーが発生しました。

問題

ssh-keygen -t rsaで公開鍵、秘密鍵を作成後、公開鍵をGitHubに登録
登録後、ssh -T git@github.comで疎通確認したところ認証されない。

$ ssh -T git@github.com
git@github.com: Permission denied (publickey).

原因

configファイルに定義していなかったため
社用のGitHubアカウントを定義しており、今回追加したアカウントがうまくよみこめていなかった。

解決方法

configファイルに以下を追記する

Host github github.com
  HostName github.com
  IdentityFile ~/.ssh/id_git_rsa #ここに自分の鍵のファイル名
  User git

おわりに

参考にした記事が非常にわかりやすかったです。

参考文献

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