Git on Windows: core.sshCommand and Quoting

Git on Windows frequently needs to be told which SSH executable to use — most commonly to point it at Windows’ built-in OpenSSH client rather than Git’s bundled one. That’s done with the core.sshCommand config option, and the quoting around the path is the part that bites.

The problem

core.sshCommand is passed through a shell, so a Windows path containing spaces and backslashes must be quoted or the SSH invocation is misparsed — Git may fail to connect or SSH may not see all of its arguments. Because PowerShell treats double quotes specially, the reliable form wraps the path in single quotes inside the outer double-quoted config string:

# Point Git at Windows' built-in OpenSSH client
git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"

The pattern is: outer double quotes for the command line, inner single quotes around the executable path. This ensures Git invokes exactly that binary with its full argument list intact.

Why the built-in client

Using C:\Windows\System32\OpenSSH\ssh.exe lets Git share the Windows user-agent / known-hosts store and any system-configured SSH setup, rather than maintaining a second, bundled copy of OpenSSH with its own config — one fewer divergence to debug.

Notes

  • Verify the result with git config --global core.sshCommand and a git ls-remote / ssh -T against the remote.
  • The same quoting rule applies to any Git config option that takes a Windows path with spaces (e.g., custom diff/merge tool paths).

Sources