9

Executing ssh on cygwin under windows 10 recently started failing, after many years of stable logins. The relevant output from ssh under a mintty from Xwindows:

%  ssh -tt -vvv <user@host>
debug3: Failed to open file:C:\\ProgramData\\ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:\\ProgramData\\ssh/ssh_known_hosts2 error:2
debug3: failed to open file:/dev/tty error:3
debug1: read_passphrase: can't open /dev/tty: No such file or directory
debug3: spawning /usr/X11R6/bin/ssh-askpass
CreateProcessW failed error:2
ssh_askpass: posix_spawn: No such file or directory
Host key verification failed.

The special file /dev/tty is there:

% ls -la /dev/tty
crw-rw-rw- 1 jpmattia None 5, 0 May 22 15:04 /dev/tty

I updated Cygwin to make sure all the binaries were the latest. Also windows updated itself earlier this week.

I'm a little baffled as to what might be going on. Clues gratefully accepted.

JP Mattia
  • 301
  • 1
  • 2
  • 10

2 Answers2

11

Documenting my solution in case anyone else has the problem: It appears that a Windows version of OpenSSH was introduced in the 2018 spring update, and it is being called instead of Cygwin's ssh. (See e.g. https://www.zdnet.com/article/openssh-arrives-in-windows-10-spring-update/)

% which ssh
/cygdrive/c/WINDOWS/System32/OpenSSH/ssh

The reason for the sudden problem with ssh is that the cygwin PATH has /cygdrive/c/WINDOWS/System32 ahead of /usr/bin/. Or at least, mine did.

So the issue is solved by calling /usr/bin/ssh explicitly. (Reordering the PATH is also a possible solution, but not for my environment.)

JP Mattia
  • 301
  • 1
  • 2
  • 10
  • 2
    /usr/bin does not include `ssh` on my fresh installation of Cygwin :( – Christoph Geschwind Jul 08 '18 at 16:13
  • Good point: My cygwin ssh probably came in with the openssl package from the Cygwin installer. – JP Mattia Jul 09 '18 at 18:37
  • 3
    Cygwin has an openssh package that must be installed to get the ssh client and ssh client tools. – Jason Slobotski Aug 04 '18 at 02:20
  • 3
    As other comments have hinted at, you must also install `openssh`, as it is **not** installed by default. – timelmer Dec 05 '18 at 04:27
  • 2
    if you install openssh (by re-running cygwin installer and selecting the openssh package), "which ssh" command should switch to show "usr/bin/ssh" instead of "cygdrive/c/WINDOWS/..." (without any additional manual path reordering) – VeraKozya Feb 04 '19 at 19:30
  • p.s. If you need cygwin's usr/bin/ssh to use your original windows ~\.ssh\config, go to C:\cygwin64\etc\nsswitch.conf and set `db_home: /%H` – VeraKozya Feb 04 '19 at 20:19
  • 1
    I had the same problem when /usr/bin/ssh was not executable after a move from C to D. Worth mentioning since the error message is so obscure. – rickfoosusa Jan 22 '21 at 00:36
3

If A fresh install of cygwin and having the sames issues, make sure to select openssh packages as part of the installation

The ssh client come with windows 10 only can be used via cmd.exe not cygwin terminal

skelator
  • 31
  • 2