Is there a way to set the GIT_SSH environment variable in the gitconfig file?
-
1What do you want to put into the GIT_SSH variable? Some settings may also be done in ~/.ssh/config instead. – Slaven Rezic Aug 05 '13 at 13:15
-
1In my case, I usually use PuTTY for handling Git, as it is quite compatible and has a solid SSH agent. However, some Git repos I use have interactive login and PuTTY doesn't handle this. For those, I need to use the SSH client that Git for Windows came with. I'd rather have `GIT_SSH` set in the config per-repo. – Brad Aug 08 '17 at 18:10
2 Answers
Since my 2013 answer (Git 1.8.3.4), a new configuration has been set: core.sshCommand
If this variable is set,
git fetch
andgit push
will use the specified command instead ofssh
when they need to connect to a remote system.
The command is in the same form as theGIT_SSH_COMMAND
environment variable and is overridden when the environment variable is set.
It has been introduced in Git 2.10, commit 3c8ede3, June 2016
Since then, you have Git 2.13, commit dd33e077, Feb. 2017, which has ssh.variant
Depending on the value of the environment variables
GIT_SSH
orGIT_SSH_COMMAND
, or the config settingcore.sshCommand
, Git auto-detects whether to adjust its command-line parameters for use with plink or tortoiseplink, as opposed to the default (OpenSSH).The config variable
ssh.variant
can be set to override this auto-detection; valid values aressh
,plink
,putty
ortortoiseplink
.
Any other value will be treated as normal ssh. This setting can be overridden via the environment variableGIT_SSH_VARIANT
.
For those, I need to use the SSH client that Git for Windows came with
So for the repos where you need ssh instead of putty, you can use both settings to set exactly in your configuration what you want.
cd /path/to/my/repo
git config ssh.variant ssh

- 1,262,500
- 529
- 4,410
- 5,250
GIT_SSH
isn't mentioned in the git config
man page.
"Git clone with custom SSH using GIT_SSH error" describes how to pass option to GIT_SSH
, but illustrates that it isn't part of a git repo config.
-
Thanks for your help! Is there any other way to automate setting the GIT-SSH environment variable as gitconfig would if the option existed? – voltair Aug 04 '13 at 21:41
-
1@voltair on unix, it would be in your.profile, or your.bashrc. On Windows, it would be registered in your user environment variables. – VonC Aug 04 '13 at 21:56