.ssh/config で設定簡単使い分け

GitHub も Bitbucket も全然使いこなしてないけど、ssh で簡単に使い分けたい。
.ssh/config で設定すれば良いようだ。

.ssh/config

Host for_git
  User git
  Port 22
  HostName github.com
  IdentityFile ~/.ssh/git_key
  TCPKeepAlive yes
  IdentitiesOnly yes

Host for_bb
  User git
  Port 22
  HostName bitbucket.org
  IdentityFile ~/.ssh/bitbucket_key
  TCPKeepAlive yes
  IdentitiesOnly yes

こんな感じに設定しておいて、リモートリポジトリを設定するときにこんなふうに。

git remote add origin for_bb:username/repository_name.git

あら簡単!