"Cannot spawn ssh" when connecting to Github, but ssh -T [email protected] works?

In my case setting GIT_SSH to:

GIT_SSH=/c/Program\ Files\ (x86)/Git/bin/ssh.exe

worked in git bash.


None of the answers so far worked for me. What ended up fixing this issue for me was removing quotes from my GIT_SSH variable and don't escape any characters at all, no MSYS path style (eg. /c/path\ to\ putty/plink.exe). Just enter the path normally, Git handles the quoting.

set GIT_SSH=C:\path to putty\plink.exe

That's it. When using GIT_TRACE you can see that the variable gets quoted in the resulting command so:

  1. the added double quotes change the string passed to the command and

  2. the path is wrapped in single quotes so the spaces are ok.

Hope that helps someone.


Have you tried installing ssh.exe to a path that does not contain spaces? And have you tested whether quoting backslashes works (\\)?

You could also try GIT_TRACE=2 git clone <...>, it should show you the command and parameters git is trying to run for connecting.