Last weekend I took some time to configure Git (and Gitolite for easier repository access management) on my Ubuntu server. It was a fun experience for a Linux newbie. Anyway, here are a bunch of things to watch out when configuring Git client on Windows.
If you want to use OpenSSH (SSH that comes with Git)
- Always generate public/private key pair using ssh-keygen -r rsa even when using PuTTY. (I initially made a mistake because I used Puttygen).
- Set the environment variable HOME=C:\Users\[USERNAME], this variable isn’t set by default. SSH looks for private keys in the C:\Users\[USERNAME]\.ssh folder. Not sure whether there are options to instruct it to looks elsewhere.
- Use default key name which is id_rsa. From what I can tell SSH looks for identity and id_rsa names (no suffixes).
When using PuTTY (an alternative to OpenSSH)
- Set environment variable GIT_SSH = C:\Program Files (x86)\PuTTY\plink.exe (path valid for x64 system). This variable will tell Git what library to use for SSH communication.
- Run Pageant (part of PuTTY distribution) which will handle your private keys. Added bonus is that you don’t have to repeat passphrase to private key when accessing it (granted you set the passphrase when you created the key – always a good practice).
Other tip would include trying the SSH connection to the server first using verbose output: SSH -vvv [USERONSERVER]@[SERVER]. This output helps to a certain extent.