39

I use Windows10 and I need to use a jumphost to get to my Linux servers. Thus I have configured my .ssh\config like so:

Host jumphost
HostName jumphost.server.local

Host server*.server.local
ProxyCommand  ssh jumphost netcat -w 120 %h %p

But when I run ssh server01.server.local -v (dash-v for verbose) I get the following error:

OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Reading configuration data C:\\Users\\admin/.ssh/config
debug1: C:\\Users\\admin/ssh/config line 70: Applying options for server*.server.local
debug1: Executing proxy command: exec ssh jumphost netcat -w 120 server01.server.local 22
CreateProcessW failed error:2
posix_spawn: No such file or directory
Chris
  • 881
  • 1
  • 7
  • 10

5 Answers5

39

As per this bug, the fix is to use a full path. So this is the correct line in the .ssh/config:

  ProxyCommand  C:\Windows\System32\OpenSSH\ssh.exe jumphost netcat -w 120 %h %p

For further development see this issue: https://github.com/microsoft/vscode-remote-release/issues/18

johnymachine
  • 190
  • 1
  • 2
  • 12
Chris
  • 881
  • 1
  • 7
  • 10
  • 8
    Thank you thank you- just likely saved me hours of frustration after updating to 1809 – nickpish Apr 04 '19 at 16:15
  • If you don't mind installing/running third party software, MobaXterm (free for personal use, no online activation needed) includes a ssh version that works correctly with "-J" parameter. Also it can correctly make use of Windows Subsystem for Linux which also can be upgraded to an ubuntu version (bionic) which contains a correctly working "-J" ssh version. Both variants allow running directly from command line without having to alter configuration files – Costin Gușă Oct 22 '19 at 11:47
  • [continuation from previous comment] The first option also includes native ssh-agent communication with putty's pageant.exe so it can use the pageant loaded keys. – Costin Gușă Oct 22 '19 at 11:58
  • Is it possible to make this work without a config file (using only -J and -o parameters)? – Åsmund Oct 07 '20 at 11:17
33

TL;DR

The ProxyCommand should invoke ssh with .exe extension, for example:

ProxyCommand ssh.exe -q -W %h:%p yyy

The long(?) story

Running ssh -vvv XXX shows:

debug3: spawning "C:\\Windows\\System32\\OpenSSH\\ssh -q -W XXX:22 YYY"
CreateProcessW failed error:2
posix_spawn: No such file or directory

According to CreateProcess document on MSDN, I guess posix_spawn is calling CreateProcess in a way that lpApplicationName argument must be exact and absolute path. After specifying the .exe suffix, it seems to be fixed.

Bruno De Fraine
  • 132
  • 1
  • 7
Ben
  • 431
  • 4
  • 6
4

I got same error but it was because of DISPLAY environment variable set to some value. Once you unset that environment variable, the error went away.

Shital Shah
  • 141
  • 3
1

This issue has to do with a bug in the OpenSSH Windows implementaiton. This bug is fixed with release 8.1.0.0. Detailed instructions on how to patch the version can be found here

hperrot
  • 11
  • 1
0

Since netcat is not available on a default system, the following two entries in the .ssh/config will do the trick (assuming that the local username and the remote username are distinct).

login.bar : system to login
jump.bar : jumphost
<username> : remote user name on login.bar and jump.bar (if they are distinct <jumpuser>@jump.bar is needed). If you omit <username>@ in front of jump.bar the local username is taken.

a)

Host foo
User <username>
HostName login.bar
ProxyCommand C:\Windows\System32\OpenSSH\ssh.exe -q -X -W %h:%p <username>@jump.bar

b)

Host foo
User <username>
HostName login.bar
ProxyCommand C:\Windows\System32\OpenSSH\ssh.exe -Y <username>@jump.bar -W %h:%p 

In both cases login to login.bar with: ssh foo