既にssh鍵(id_rsa)は他で使っていたので、新しく鍵を作って両方を併用したい。
$ ssh-keygen -C "foge_at_gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/foo/.ssh/id_rsa): github_id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in github_id_rsa.
Your public key has been saved in github_id_rsa.pub.
.
.
$ mv github_id_rsa ~/.ssh/github_id_rsa
github_id_rsa.pubをgithubに登録
~/.ssh/configに以下を追加
Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
接続テスト
$ ssh git@github.com
PTY allocation request failed on channel 0
Hi fogefoge-foo! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
successfully authenticated って出たらOKらしい