Win32-OpenSSH icon indicating copy to clipboard operation
Win32-OpenSSH copied to clipboard

ssh client on Windows7 fails with: ssh_askpass: fork: No such file or directory

Open christian-korneck opened this issue 9 years ago • 18 comments

Please answer the following

"OpenSSH for Windows" version ((Get-Item (Get-Command sshd).Source).VersionInfo.FileVersion) tested with versions 0.0.23.0 and 0.0.18.0

Server OperatingSystem ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\" -Name ProductName).ProductName) any server on any OS - it's a client issue (tested against various servers, both Linux and sshd on localhost running on Win7 SP1 Ultimate)

Client OperatingSystem Windows 7 SP1 Ultimate

What is failing On Windows 7, I can't connect to any ssh server using the ssh.exe client from this project. The servers that I've tested all have password auth. The key error message is: ssh_askpass: fork: No such file or directory.

On Windows 10 (tested with Win10-1709) and on Windows 8.1, the same ssh.exe binary works as expected (connections against the same servers). On the Windows 7 host, the same connections work using a different ssh client (i.e. putty). Same effect both with the 32bit and 64 bit ssh.exe.

I have tried ssh.exe both in version 0.0.23.0 and 0.0.18.0 (the version that ships as capability/optional feature in Win10-1709) without success.

Expected output

> ssh.exe [email protected]
[email protected]'s password:
NetBSD 7.1 (GENERIC.201703111743Z)

     *    . @%@%@%@%@%@%@ (    )
     (      {   happy   }  \  (   *
      ) *   { birthday! }   )    (
     (    @%@%@%@%@%@%@%@%@       ) '
   +      {    SDF 30!    }  *   (
          {  1987 - 2017  }    .    )
    jgs   {    June 16    }        (
  *      @%@%@%@%@%@%@%@%@%@    +

Actual output

> ssh.exe [email protected]
key_load_public: invalid format
ssh_askpass: fork: No such file or directory
Host key verification failed.
PS C:\Windows\System32\WindowsPowerShell\v1.0>

christian-korneck avatar Nov 26 '17 08:11 christian-korneck

ok, I think I figured it out. On my Windows 7 machine the environment variable DISPLAY=localhost:0.0 was set. Removing/Renaming this variable resolved the issue.

While it was set, my c:\Program Files\OpenSSH\ssh.exe was trying to execute c:\Program Files\OpenSSH\usr\X11R6\bin\ssh-askpass.exe, which doesn't exist (seen with a procmon trace).

christian-korneck avatar Nov 26 '17 09:11 christian-korneck

Thanks for following up.

manojampalam avatar Nov 28 '17 17:11 manojampalam

Why does it matter that the DISPLAY environment variable is set? That shouldn't lead to something asking for a password any differently than it would otherwise!

I am experiencing the same trouble with X11 forwarding described here, but I can't leverage their solution of setting the DISPLAY on the client side, because OpenSSH then throws these complaints about permissions being strangely denied.

pavelkomarov avatar Nov 29 '18 21:11 pavelkomarov

I agree with @pavelkomarov . It looks like a bug to me. Any chance that this issue could get re-opened?

christian-korneck avatar Nov 29 '18 22:11 christian-korneck

I agree with @pavelkomarov as well. Why should the display variable matter?

Error-101 avatar Dec 06 '18 15:12 Error-101

Why does it matter that the DISPLAY environment variable is set? That shouldn't lead to something asking for a password any differently than it would otherwise!

I am experiencing the same trouble with X11 forwarding described here, but I can't leverage their solution of setting the DISPLAY on the client side, because OpenSSH then throws these complaints about permissions being strangely denied.

Wish you found a solution. The posix_spawn related error seems related to cmd, when I use powershell, the error is gone. but x forwarding still doesn't work.

duhd1993 avatar Dec 06 '18 21:12 duhd1993

@christian-korneck 's solution worked. In my Windows 10 cmd terminal, DISPLAY=:0.0, scp failed with: " CreateProcessW failed error:2 ssh_askpass: posix_spawn: No such file or directory Host key verification failed. lost connection" I removed the env variable by "set DISPLAY=". Then scp copied files successfully.

forester-guo-gmail-com avatar Jan 17 '19 18:01 forester-guo-gmail-com

Yeah, but it's a work-around. The bug remains.

pavelkomarov avatar Jan 17 '19 19:01 pavelkomarov

This is an interesting bug. It happens because when DISPLAY is defined and there is no accessible tty (console, terminal, etc), it wants to fallback to requesting password by some external application call. Now, the problem is that the check for an available console is done by opening /dev/tty. This works perfectly well on *nix platforms, but on Windows the corresponding thing should really be to open CON or CONIN$ instead.

As a workaround it seems that it is possible to create a directory C:\dev with an empty file called tty, so that the path \dev\tty can be opened. Just tested that and it seems to work.

I'll try to build a version with CON instead of /dev/tty for Windows builds and see what happens.

Olof-Lagerkvist avatar Feb 08 '19 22:02 Olof-Lagerkvist

Yes. At line 457 in define.h, changed:

#ifndef _PATH_TTY # define _PATH_TTY "/dev/tty" #endif

to

#ifndef _PATH_TTY # ifdef _WIN32 # define _PATH_TTY "conin$" # else # define _PATH_TTY "/dev/tty" # endif #endif

And everything seems to work correctly even with DISPLAY variable set now. It even sets up X11 forwarding correctly as far as I can see (provided XauthLocation is set to a working xauth setup in ssh_config).

Olof-Lagerkvist avatar Feb 09 '19 00:02 Olof-Lagerkvist

@LTRData So this is now fixed? When it will be available in Windows?

filips123 avatar Feb 25 '19 18:02 filips123

The workaround of creating /dev/tty works in Windows 10 1809 (OS Build 17763.615) with the ssh.exe that ships with Windows 10 now:


CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     ssh.exe                                            7.7.2.1    C:\WINDOWS\System32\OpenSSH\ssh.exe

This was driving me crazy.

obscurerichard avatar Jul 13 '19 14:07 obscurerichard

nice!

christian-korneck avatar Jul 13 '19 14:07 christian-korneck

if you are using ssh with a different drive other than C: then you need to add the dev/tty folder to that drive as well.

snaphat avatar Sep 05 '19 19:09 snaphat

See also #1088 (where the same workaround is mentioned).

psz2036 avatar Oct 08 '19 01:10 psz2036

on Windows 10, I am able to log in using ssh. But using rsync and ssh was not successful, even with the \dev\tty hack.

xianwenchen avatar Jan 20 '20 21:01 xianwenchen

I had this too... create an empty file on the path: C:\dev\tty

emhacker avatar Oct 01 '20 17:10 emhacker

creating an empty file c:\dev\tty solved the problem for me too. I am using win 10 ver 20H2 and Build 19042.685.

HadiJalali avatar Jan 10 '21 16:01 HadiJalali