はじめに
SSH の鍵を、ホストやユーザごとに切り替える設定を記載します。
客先やプロジェクト毎に、Git管理サービスのユーザやホストが変わって面倒な場合があるやつです。
環境
ちなみに、筆者の環境は Windows 10 です。
記載内容は関係ないですが、config ファイルのありかは環境依存になると思います。
config ファイルのありか:C:\Users\your_user_name\.ssh\config
ユーザごとに切り替える設定
Host bitbucket.org
Hostname bitbucket.org
IdentityFile ~/.ssh/id_rsa_for_tanaka_private
IdentitiesOnly yes
User tanaka_private
Host bitbucket.org
Hostname bitbucket.org
IdentityFile ~/.ssh/id_rsa_for_tanaka_work
IdentitiesOnly yes
User tanaka_work
ホストごとに切り替える設定
Host hoge.git.backlog.jp
Hostname hoge.git.backlog.jp
IdentityFile ~/.ssh/id_rsa_for_hoge
IdentitiesOnly yes
Host foo.git.backlog.jp
Hostname foo.git.backlog.jp
IdentityFile ~/.ssh/id_rsa_for_foo
IdentitiesOnly yes