LoginSignup
4
8

More than 5 years have passed since last update.

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

Last updated at Posted at 2015-10-18

問題

githubとの接続を確認しようと思って

$ ssh -T git@github.com

を打つと

Permission denied (publickey).

githubのpullもpushもうまくいっていてあれっと思いました。

解決策

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

*-i のオプションでは自分のgithubとの接続で使用している秘密鍵を使います。

ssh接続の際「~/.ssh/id_rsa」、「~/.ssh/id_dsa」、「~/.ssh/identity」しかデフォルトでは見にいきません。今回はこの3つ以外の名前の秘密鍵だったので鍵を指定しないといけませんでした。

ちなみに
~/.ssh/configに以下のように設定しているので

Host github
  HostName github.com
  IdentityFile ~/.ssh/id_git_rsa
  User git

これでもいけます。

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

また、以下でうまくいかないのも気にくわないので、

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

以下のように記述すると

Host github github.com
  HostName github.com
  IdentityFile ~/.ssh/id_git_rsa
  User git

うまくいきますね!

$ ssh -T git@github.com                                                                                                                                                                 
Hi kuboshizuma! You've successfully authenticated, but GitHub does not provide shell access.
4
8
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
4
8