6

I want to figure which SSH client is used by git commands when running git bash on windows. Is there any git command I can run that will display the ssh client path?

shugigo
  • 133
  • 1
  • 10

1 Answers1

4

With a recent enough git version, you can use trace2 to display what Git is trying to do:

GIT_TRACE2=1 git clone git@github.com:<me>/<myrepo>
GIT_TRACE2_EVENT=1 git clone git@github.com:<me>/<myrepo>

You can also set the GIT_SSH_COMMAND environment variable to ssh (including its full path) if you want to make sure which SSH client is used.


Jacob Stamm adds in the comments, to illustrate that approach:

I was working in a Docker container from Windows, and from within the container, Git was trying to use C:\Windows\System32\OpenSSH\ssh.exe for SSH and failing.

Setting ENV GIT_SSH_COMMAND /usr/bin/ssh in my Dockerfile and rebuilding my container solved the issue. T

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This will show something like `child_start[0] ssh ...` which isn't terribly helpful since its still unclear which `ssh` is run. – CervEd Nov 10 '21 at 10:13
  • @CervEd "which ssh"? Do you mean you have multiple ssh installed? – VonC Nov 10 '21 at 10:17
  • with Git for Windows one might have both the Git for Windows OpenSSH client as well as the Windows OpenSSH client, both as `ssh`. If running `which ssh` returns what is later run by the git process that's great. In my case I had switched back to the Git for Windows `ssh` client, `which ssh` returned `/usr/bin/ssh` – CervEd Nov 10 '21 at 10:31
  • @CervEd True. I always set the PATH to make sure to use the Git For Windows SSH one. – VonC Nov 10 '21 at 11:09
  • I recently installed on a new machine using the new option to use the native client but found myself reverting. Then I got problems with handshakes and I just wanted to make sure which client was being used – CervEd Nov 10 '21 at 11:36
  • 1
    I was working [in a Docker container from Windows](https://code.visualstudio.com/docs/devcontainers/containers), and from within the container, git was trying to use `C:\Windows\System32\OpenSSH\ssh.exe` for SSH and failing. Setting `ENV GIT_SSH_COMMAND /usr/bin/ssh` in my Dockerfile and rebuilding my container solved the issue. Thanks! – Jacob Stamm Oct 28 '22 at 18:51
  • @JacobStamm Thank you for this feedback, well done! I have included your comment in the answer for more visibility. – VonC Oct 28 '22 at 20:11