Issue
I have 2 Git servers that require 2 different SSH keys.
git clone user1@server1:blahblahblah
uses ~/.ssh/id_rsa
, but I need to specify which key to use depending on the server I am connecting to.
What Git command-line parameter does this job? (I am running Linux.)
Solution
If you are connecting via SSH then the key will be controlled by an SSH parameter, not a git parameter.
SSH looks in the ~/.ssh/config
file for configuration parameters. Modify that file and add IdentityFile entries for the two Git servers like this:
Host server1.whatever.com
IdentityFile /path/to/key_1
Host server2.whatever.com
IdentityFile /path/to/key_2
This article has some more details.
Answered By - Cameron Skinner Answer Checked By - Cary Denson (WPSolving Admin)