[Gehirn RS2] SSHキーをBitbucketに登録してgitコマンドを使えるようにする - Qiita
http://qiita.com/MegaBlackLabel/items/54f2a874acda6cb763f0
ssh-keygen
の -C
オプションはコメント。指定しないと ユーザー名@コンピュータ名
のようになる。
-f
オプションで保存するファイル名を指定する。
% cd ~/.ssh
% mkdir github
% ssh-keygen -t rsa -C "foomin10@gmail.com" -f "github/id_rsa"
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
% chmod 600 github/id_rsa
% cd ~/.ssh
% mkdir bitbucket
% ssh-keygen -t rsa -C "foomin10@gmail.com" -f "bitbucket/id_rsa"
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
% chmod 600 bitbucket/id_rsa
~/.ssh/config
を作成する
Host github.com
IdentityFile ~/.ssh/github/id_rsa
User git
HostName github.com
Port 22
TCPKeepAlive yes
IdentitiesOnly yes
Host bitbucket.org
IdentityFile ~/.ssh/bitbucket/id_rsa
User git
HostName bitbucket.org
Port 22
TCPKeepAlive yes
IdentitiesOnly yes
chmod 600 ~/.ssh/config
でパーミッションを設定
-
[Add SSH key]
-
Title
github/id_rsa.pub
-
Key
~/.ssh/github/id_rsa.pub
の中身を貼り付け
-
[鍵を追加]
-
Label
bitbucket/id_rsa.pub
-
Key
~/.ssh/bitbucket/id_rsa.pub
の中身を貼り付け
% ssh -T git@github.com
Hi foomin10! You've successfully authenticated, but GitHub does not provide shell access.
% ssh -T git@bitbucket.org
logged in as foomin10.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
~/
.ssh/
bitbucket/
id_rsa
id_rsa.pub
github/
id_rsa
id_rsa.pub
config
known_hosts