7

I installed Cygwin and sshd on Windows 7 but I'm not able to make it work.

I followed the guide from http://www.noah.org/ssh/cygwin-sshd.html but I still get:

$ cygrunsrv -S sshd
cygrunsrv: Error starting a service: QueryServiceStatus:  Win32 error 1062:
The service has not been started.

Configuration details:

  • Windows 7 in a domain running with a domain user that has local administrative priviledges
  • netstat -a -b reports nothing running on port 22
  • C:\cygwin\var\log\sshd.log is empty
  • After I installed cygwin and sshd, I run ssh-host-config -y
  • Already tried to add SYSTEM account to the 3 directories, no change.
  • Already tried a full system reboot, no change

Update: Windows logs complains about Possible duplicate cygwin1.dll

2
  • Have you solved this yet? I am having similar problems?
    – Lord Loh.
    Feb 18, 2012 at 21:21
  • i've foudn i can reproduce this error by going to services.msc cygwin sshd logon tab, and switching between local account(cyg_server), and system. each time there's a change, it needs an ssh-host-config -y done from a command prompt started via right click run as administrator, or from a runas /user:Administrator c:\windows\system32\cmd.exe That ssh-host-config -y must precede the net start sshd / cygrunsrv -S sshd. And if it doesn't work from a 'run as admin..' try from a runas/user:... cmd prompt.
    – barlop
    May 13, 2015 at 2:46

11 Answers 11

7

Thanks, Your update was the resolution - for anyone else out there, there is a recipe #3 against Win32 error 1062 at Cygwin startup:

1) Check the Application Event log, see if there are "Information"-level events there with something like: "sshd: PID : Possible duplicate cygwin1.dll:"

Find that silly duplicate at the specified location and rename it or get rid of it from the path somehow. Mine was at "/cygdrive/c/Program Files (x86)/socat-1.7.2.0/cygwin1.dll."

Boo, socat! Apparently they engage in 3PP. Didn't even know socat was on my system, apparently it came as a part of some other installation. I found 2 other people in the cygwin mailing lists having suffered from the duplicate-dll problem.

1
  • Really it could be many many things, that^ but also config issues and who knows what - best look at /var/log/sshd.log
    – nhed
    Jul 25, 2017 at 0:12
2

Thank you @HopelessN00b, @user155148, @Algomorph a combination of your solutions got me going.

The Crux

I had two problems:

  1. Duplicate cygwin1.dll files.
  2. /var/log/sshd.log: "Privilege separation user sshd does not exist"

My Fix

  1. Deal with the duplicate pickle files:

     cd /cygdrive/c/Program\ Files\ \(x86\)/cwRsync/bin
     mv cygwin1.dll cygwin1_.dll
    
  2. Added a user by editing /etc/passwd and adding the following line:

     sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
    

Note that the username 'sshd' came from /var/log/sshd.log.


I did find one other resource, this one a bit more verbose and from Oracle

In a nutshell, if you are having greif:

  1. Run each of these steps ONE. AT. A. BLOODY. TIME.
    ...make the fix
    .....run cygrunsrv -S sshd
    .......curse profusely
  2. Check the Windoze event logs.
    ...Do you have duplicate dll files??
  3. Take a look at /var/log/sshd.log
    ...Do you have /etc/passwd probs?
1

I had (almost) the same effect and an analogous solution: Application log showed a duplicate file

Possible duplicate cygwin1.dll: /cygdrive/c/dakota/bin/cygwin1.dll..

from my dakota installation. Renaming this dll did the trick. Thank you!

1

I had some privilege separation problem. In this case adding a line to /etc/passwd file solved the problem.

sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin

1

For me it turned out to be a compatibility issue. I was trying to run it in Win7. Fixed by right clicking the file in explorer, going to compatibility and setting compatibility to Windows Server 2003. Worked fine after that.

Found the solution here:

http://h30499.www3.hp.com/t5/Windows-Server-2008/Installing-OpenSSH-on-Windows-server-2008/td-p/4777839#.U0cmzle2wuI

Note that my issue was related specifically to trying to launch OpenSSH Server which uses a light version of Cygwin I guess.

1

I use a local account, cyg_server, to run sshd. I needed to set the permissions on /var/empty to 700 and the owner to cyg_server, despite the fact that the error message said that the owner needs to be root.

I also removed the message of the day (/etc/motd), but I don't think that this is strictly necessary. It sometimes gets in the way of my automation.

FWIW, cyg_server is a strictly local user with admin privileges and no Active Directory definition. It is listed in the registry and in /etc/passwd.

I also had to edit the rights of cyg_server after accepting a recent Cygwin update.

cygrunsrv -E sshd
editrights -a SeAssignPrimaryTokenPrivilege -u cyg_server
editrights -a SeCreateTokenPrivilege -u cyg_server
editrights -a SeTcbPrivilege -u cyg_server
editrights -a SeServiceLogonRight -u cyg_server
cygrunsrv -S sshd

stopped sshd, changed the service account's rights and restarted sshd.

This is how the rights are set after this quick session.

bash-4.4$  editrights -u cyg_server -l
SeAssignPrimaryTokenPrivilege
SeCreateTokenPrivilege
SeTcbPrivilege
SeServiceLogonRight
SeDenyRemoteInteractiveLogonRight
bash-4.4$ 
0

The /etc/passwd response was very close, but the UID 74 was specific to his installation.

instead use this cygwin command to grab the correct UID.

mkpasswd -l -u sshd >> /etc/passwd

0

This seems to be caused by ANY error with the sshd server - in my case it barfed on /etc/ssh_host_rsa_key perms - should be 0600. look in /var/log/sshd or similar.

0

On a client system I found a program called RDPlus (www.rdplus.com.au) running an SSH tunneling option on port 22 that I had to disable before Cygwin sshd would start. From CMD.EXE, 'netstat -abo' pointed at this process after finding an 'Bind to port 22 on 0.0.0.0 failed' error in the Application Event Log. The 'o' option will show the PID which can be found in Task Manager.

To disable this run the RDPlus admin tool, go to the Web tab and disable SSH Tunneling.

0

Someone posted this on another Stack Exchange question, but in case you have a empty file in /var/log/sshd, you should try /usr/sbin/sshd. This will output the errors you didn't get in the log.

For me, unistalling the sshd services, rebooting and then re-running ssh-host-config, while following these instructions, helped (ls -l /var/etc told me that in my first attempt, the empty folder was owned by SYSTEM, which makes sense, since I followed this tutorial previously. However, this way, I got a "/var/empty must be owned by root and not group or world-writable" error).

0

I was using Cntlm (NTLM authentication proxy) which contains cygwin1.dll too, avoidance of such duplication resolved the issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .