Providing proxy to ssh command or putty via cmd in Windows

Viewed 1399

I want to establish an SSH connection providing a proxy via command Line in Windows. While I use ssh command with ssh -o "ProxyCommand proxytunnel.exe ..." it gives me an error like

CreateProcessW failed error:2 posix_spawn: No such file or directory

Also with putty.exe command line I tried -proxycmd="proxytunnel.exe .." but this is giving error as well.

Any recommended way to establish an SSH connection providing a proxy via CMD?

Thanks in advance!

1 Answers

The syntax on a normal system is (but not on windows):

ssh user@myHost -p 4711 -oProxyCommand="ssh jumphost -W %h:%p"

or with proxytunnel

ssh user@myHost -p 4711 -oProxyCommand="proxytunnnel.exe args"

The comment from @MartinPrikryl reminds me of another problem.
The message CreateProcessW failed error:2 posix_spawn: No such file or directory is typical for a windows 10 system, because the ssh isn't able to find even ssh.exe itself in the ProxyCommand option.

You always need to specify the full path on windows, even the .exe is required.

ssh user@myHost -p 4711 -oProxyCommand="C:\Windows\System32\OpenSSH\ssh.exe jumphost -W %h:%p"

To use a full path in the .ssh/config file is possible (best with forward slashed), but leads to more problems, when you are using git-bash, then the ssh-agent breaks regulary.

Or better avoid to use the OpenSSH from windows at all and use always the ssh from git-bash, as this works much better and works also reliable with the ssh-agent (The ssh-agent from git-bash).
Then it's even possible to use vscode via a jumphost without headach.

Related