Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
christian-korneck opened this issue Nov 26, 2017 · 18 comments

Comments

@christian-korneck
Copy link

christian-korneck commented Nov 26, 2017

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 christian-korneck changed the title ssh client on Windows7 fails with ssh_askpass: fork: No such file or directory ssh client on Windows7 fails with: ssh_askpass: fork: No such file or directory Nov 26, 2017
@christian-korneck
Copy link
Author

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).

@manojampalam
Copy link
Contributor

Thanks for following up.

@pavelkomarov
Copy link

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.

@christian-korneck
Copy link
Author

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

@Error-101
Copy link

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

@duhd1993
Copy link

duhd1993 commented Dec 6, 2018

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.

@forester-guo-gmail-com
Copy link

@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.

@pavelkomarov
Copy link

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

@LTRData
Copy link

LTRData commented Feb 8, 2019

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.

@LTRData
Copy link

LTRData commented Feb 9, 2019

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).

@filips123
Copy link

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

@obscurerichard
Copy link

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.

@christian-korneck
Copy link
Author

nice!

@snaphat
Copy link

snaphat commented Sep 5, 2019

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.

@psz2036
Copy link

psz2036 commented Oct 8, 2019

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

@xianwenchen
Copy link

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.

AJDurant added a commit to AJDurant/openssh-portable that referenced this issue Jun 23, 2020
Currently openssh tests for a TTY by opening /dev/tty which does not exist on Windows. It most cases this then falls back to a prompt that works, but if the DISPLAY env var is set, then it tries to spawn "/usr/X11R6/bin/ssh-askpass" and fails - see issue #966, #1515, PowerShell#762, #1088, #1356, and probably others.

Possible workarounds are to create a file `C:\dev\tty` so that it is able to open it, or to unset the DISPLAY variable, but it would be better if OpenSSH could detect this is a valid console. Code is from PowerShell/Win32-OpenSSH#966 (comment)
@emhacker
Copy link

emhacker commented Oct 1, 2020

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

@HadiJalali
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.