Equivalent of 'ssh' config option in Hg for Git?

0

On Windows 7, my .hgrc config file provides a nice an easy way to tell Mercurial about the private SSH key location with the following syntax:

[ui]
username = John Doe <jdoe@example.com>
ssh = plink.exe -i "C:\Users\jdoe\mykeys.ppk" 

Does anyone knows what is the equivalent syntax for the .gitconfig file? All I can find so far is the GIT_SSH environment variable that does not seem to let me specify the private key location.

Joannes Vermorel

Posted 2011-08-11T13:20:45.140

Reputation: 453

Is the key used for all SSH connections, or must it limited to hg/git? – user1686 – 2011-08-11T18:44:22.323

All connections is just fine. – Joannes Vermorel – 2011-08-12T09:18:10.623

Answers

1

If you want to specify a key to be used for all connections, there are two ways to do it with PuTTY:

  1. Load the key into Pageant, the SSH agent program. Just double-click the .ppk file and enter its passphrase, if any.

    This has several advantages: you can encrypt the key on disk and still retain the convenience of password-less logins, and you can have multiple keys loaded and they all will be tried.

    (The OpenSSH equivalent of Pageant is ssh-agent, by the way.)

  2. Edit PuTTY's default configuration to point to the key. Open a new PuTTY window, go to Connection → SSH → Auth, and choose your key file under Private key file. Go back to Session, click the "Default Settings" item, and click Save.

    plink uses the same session settings as PuTTY, and will automatically use the key you configured here.

    (In OpenSSH, you would edit ~/.ssh/config to achieve the same result.)

user1686

Posted 2011-08-11T13:20:45.140

Reputation: 283 655