問題
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.