Using GIT_SSH_COMMAND in Git for Windows

I use the fourth release for Git for Windows 2.x and use GIT_SSH_COMMAND in the shell to avoid checking the SSH host. In Git Bash I am writing something like this:

$ GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git push origin master 

How can I do something like this in windows cmd? Unable to find answers.

+4
git git-bash
source share
2 answers

You no longer need to set the environment variable in Windows.

With git 2.10+ (Q3 2016) you also have the option to set the configuration for GIT_SSH_COMMAND , which is simpler than an environment variable (and it can be configured globally or locally for a specific repo)

See commit 3c8ede3 (June 26, 2016) Nguyα»…n ThΓ‘i Ngọc Duy ( pclouds ) .
(merger of Junio ​​C Hamano - gitster - on commit dc21164 , July 19, 2016

A new core.sshCommand configuration variable has been core.sshCommand specify which value for GIT_SSH_COMMAND to use for each repository.

 core.sshCommand: 

If this variable is set, git fetch and git push will use the specified command instead of ssh when they need to connect to the remote system.
The command is in the same form as the GIT_SSH_COMMAND environment GIT_SSH_COMMAND , and is overridden when the environment variable is set.

This means that git push can be:

 cd /path/to/my/repo git config core.sshCommand 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' # later on git push origin master 

With git 2.16 (Q1 2018), you will have a new mechanism for updating the wired protocol in place, and it will demonstrate that it works with older versions of git without harming them.

See commit 6464679 (October 16, 2017) and commit 0cd8328 (September 26, 2017) by Jonathan Tan ( jhowtan ) .
See commit 94b8ae5 , commit 3c88ebd , commit 19113a2 , commit 0c2f0d2 , commit 2609043 , commit aa9bab2 , commit dfe422d , commit 373d70e , commit 5d2124b (October 16, 2017) Brandon Williams ( mbrandonw ) .
(merger of Junio ​​C Hamano - gitster - on commit 4c6dad0 , December 06, 2017)

ssh : enter the option ' simple ' ssh

When using the ssh transport, the -o option is used to specify the environment variable that should be set at the remote end.
This allows git to send additional information when accessing the server, requesting the use of a different version of the protocol through ' GIT_PROTOCOL ', like so: " -o SendEnv=GIT_PROTOCOL ".

Unfortunately, not all ssh variants support sending environment variables to the remote end.
To take this into account, use the -o option for ssh variants that are compatible with OpenSSH.
This is done by verifying that the base name of the ssh command is ssh , or that the ssh variant is overridden as ssh (via the ssh.variant configuration).

Other parameters, such as " -p " and " -p ", which are used to indicate the specific port to use, or " -4 " and " -6 ", which are used to indicate that IPV4 or IPV6 addresses should be used, also cannot be supported by all ssh options.

Currently, if the base name of the ssh command was not ' plink ' or ' tortoiseplink ', git assumes that the command is a variant of OpenSSH.
Since custom ssh commands may not meet OpenSSH requirements, tighten this restriction and accept the " simple " option if the base name of the command does not match the options known as Git.
The new ssh option ' simple ' will contain only the host and the command ( [ username@ ]host command) passed as parameters to the ssh command.

+5
source share

Here is the answer:

 set GIT_SSH_COMMAND=ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no & git push origin master 
+2
source share

All Articles