鍵の名前を ssh-keygen -t rsa
で作成して id_rsa
(初期設定から)変えた場合は
$ssh -T git@github.com
がうまくいかない
ssh接続の際「~/.ssh/id_rsa」、「~/.ssh/id_dsa」、「~/.ssh/identity」しかデフォルトでは見にいかないから。
~/.ssh/configに以下を追加しないといかない
Host github github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa_git #変更したファイル名
User git
これでうまくいく
$ ssh -T github.com
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
すでにhttpでURL登録済みの場合は
$git remote set-url origin git@github.com:foobar/hogehoge.git
なお、リモートホストの確認は
$ git remote -v
鍵の中身のクリップボードへのコピーは
$ pbcopy < ~/.ssh/id_rsa.pub (Mac)
$ clip < ~/.ssh/id_rsa.pub (Windows)