LoginSignup
0
0

More than 3 years have passed since last update.

ssh の鍵を、ホストやユーザごとに切り替える設定

Posted at

はじめに

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

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0