How to use different keys for different git servers?

Posted on In QA

I have access to different git servers. I have several keys for these servers. How to use different keys for different git servers?

Use the .ssh/config file to specify different configuration for different SSH servers used by git:

For example:

Host git.example.org
  Port 22111
  IdentityFile ~/.ssh/id_rsa.git.example.org

Host code.example.org
  Port 22
  IdentityFile ~/.ssh/id_rsa.code.example.org

which specifies the port and private key file for git.example.org and code.example.org.

Leave a Reply

Your email address will not be published. Required fields are marked *