Problems Starting sshd as a service through CYGWIN

Kyle Flavin Kyle.Flavin@warnerbros.com
Thu Nov 29 21:30:00 GMT 2007


I am having trouble starting sshd as a Window's service.  I've looked 
over the mailing list archives, but have been unable to find a 
resolution to my problem.  I apologize for the length of this email, but 
I tried to include all pertinent information.  I have attached the 
output of cygcheck -s -v -r.

When I run /usr/sbin/sshd by hand from a CYGWIN terminal, it works.  I 
can remotely access the machine from another computer using SSH.  I can 
successfully install SSHD as a service, but when I try to start the 
service, it fails.  This is true even when I try to start it manually, 
after my machine has booted.  Here's the process I went through after 
installation of CYGWIN/OpenSSH/OpenSSL:

I ran ssh-host-config, and it ran without any errors.  When I ran the 
following, the service failed to start:
------------------------
$ cygrunsrv.exe -S sshd
cygrunsrv: Error starting a service: QueryServiceStatus:  Win32 error 1062:
The service has not been started.
------------------------

When I run it like this, I also get an error:
------------------------
$ net start sshd
The CYGWIN sshd service is starting.
The CYGWIN sshd service could not be started.

The service did not report an error.

More help is available by typing NET HELPMSG 3534.
------------------------


Window's Event Viewer shows the service starting, and then almost 
immediately after, stopping:
------------------------
The CYGWIN sshd service was successfully sent a start control.

The CYGWIN sshd service entered the stopped state.
------------------------


The Application log again shows the service stopping for a reason I 
cannot explain:
------------------------
The description for Event ID ( 0 ) in Source ( sshd ) cannot be found. 
The local computer may not have the necessary registry information or 
message DLL files to display messages from a remote computer. You may be 
able to use the /AUXSOURCE= flag to retrieve this description; see Help 
and Support for details. The following information is part of the event: 
sshd: PID 4956: `sshd' service stopped, exit status: 57.
------------------------

I get the same error, regardless if I run this from a Cygwin window as 
the "Administrator" user, or if I run it from a system-owned console 
window using Igor's sysbash trick.  I attempted to remove the sshd 
service, and install it manually by doing the following (note that I do 
use the "-D" option):
------------------------
$ cygrunsrv.exe --verbose -Q sshd
Service             : sshd
Display name        : CYGWIN sshd
Current State       : Stopped
Command             : /usr/sbin/sshd -D
stdin path          : /dev/null
stdout path         : /var/log/sshd.log
stderr path         : /var/log/sshd.log
Environment         : CYGWIN="ntsec tty"
Process Type        : Own Process
Startup             : Automatic
Dependencies        : tcpip
Account             : LocalSystem

$ cygrunsrv.exe --remove sshd

$ cygrunsrv.exe --install sshd -p /usr/sbin/sshd -a "-D" -y tcpip -d 
"CYGWIN sshd" -f "Cygwin SSH services"

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

$ cygrunsrv.exe --verbose -Q sshd
Service             : sshd
Display name        : CYGWIN sshd
Description         : Cygwin SSH services
Current State       : Stopped
Command             : /usr/sbin/sshd -D
stdin path          : /dev/null
stdout path         : /var/log/sshd.log
stderr path         : /var/log/sshd.log
Process Type        : Own Process
Startup             : Automatic
Dependencies        : tcpip
Account             : LocalSystem
------------------------

The cygserver service appears to be working properly:
------------------------
$ cygrunsrv.exe --verbose -Q cygserver
Service             : cygserver
Display name        : CYGWIN cygserver
Current State       : Running
Controls Accepted   : Stop
Command             : /usr/sbin/cygserver
stdin path          : /dev/null
stdout path         : /var/log/cygserver.log
stderr path         : /var/log/cygserver.log
Process Type        : Own Process
Startup             : Automatic
Account             : LocalSystem
------------------------


At this point, I uninstalled Cygwin by deleting the c:\CYGWIN folder and 
reinstalling.  After two reboots, (one after uninstalling, and one after 
reinstalling) I'm still experiencing the same issues. 


Here are my system details.  My machine is running Windows XP Pro, SP2.  
For readability, I've included some of the information from cygcheck 
(attached) here.
------------------------
$ uname -a
CYGWIN_NT-5.1 dataop 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin

$ cvgcheck -s -v -r | grep -i open
openssh              4.7p1-2
openssl              0.9.8g-1
------------------------

I checked to make sure all my mounts were system, and not user mounts:
------------------------
$ mount -m
mount -f -s -b "C:/Documents and Settings" "/home"
mount -f -s -b "C:/cygwin/bin" "/usr/bin"
mount -f -s -b "C:/cygwin/lib" "/usr/lib"
mount -f -s -b "C:/cygwin" "/"
mount -s -b --change-cygdrive-prefix "/cygdrive"
------------------------

I checked permissions on the /etc/ssh* files.  My understanding is they 
should be at least 600.  However, given that SSH runs fine from the 
command line as /usr/sbin/sshd (-d doesn't show errors), I don't think 
it's a problem with sshd.
------------------------
$ ls -l /etc/ssh*
-rwxr-x--- 1 SYSTEM None 1482 Nov 26 16:50 /etc/ssh_config
-rw------- 1 SYSTEM None  672 Nov 20 17:24 /etc/ssh_host_dsa_key
-rw-r--r-- 1 SYSTEM None  610 Nov 20 17:24 /etc/ssh_host_dsa_key.pub
-rw------- 1 SYSTEM None  983 Nov 20 17:24 /etc/ssh_host_key
-rw-r--r-- 1 SYSTEM None  647 Nov 20 17:24 /etc/ssh_host_key.pub
-rw------- 1 SYSTEM None 1675 Nov 20 17:24 /etc/ssh_host_rsa_key
-rw-r--r-- 1 SYSTEM None  402 Nov 20 17:24 /etc/ssh_host_rsa_key.pub
-rw-r--r-- 1 SYSTEM None 3198 Nov 26 16:50 /etc/sshd_config
------------------------

I chown'd the /var/empty folder to the "SYSTEM" user, and then set 
permissions on it to 777.  I also opened up permissions on /var/log.
------------------------
$ ls -l /var
total 72
drwxrwx---+ 3 Administrator Users     0 Nov 20 17:23 cache
drwxrwxrwx+ 2 SYSTEM        root      0 Nov 20 17:24 empty
drwxrwx---+ 3 Administrator Users     0 Nov 20 17:22 lib
drwxrwxrwx+ 2 Administrator Users     0 Nov 27 11:35 log
-rw-r--r--  1 Administrator None  73120 Nov 27 11:56 out
drwxrwxrwx+ 2 Administrator Users     0 Nov 20 17:26 run
drwxrwx---+ 2 Administrator Users     0 Nov 20 17:22 tmp
------------------------

Going through Windows Explorer, I added "Full Control" for the SYSTEMS 
user to the following directories.
C:\cygwin\bin
C:\cygwin\var\log
C:\cygwin\var
C:\cygwin\

Finally, I made sure that cygwin1.dll was executable by everyone.  I 
also checked for duplicate copies of this file on my system.
------------------------
$ls -l /cygdrive/c/cygwin/bin/cygwin1.dll
-rwxr-xr-x+ 1 Administrator Users 1873811 Jan 31  2007 
/cygdrive/c/cygwin/bin/cygwin1.dll
------------------------


I'm out of ideas.  Does anyone have suggestions as to what I could look 
at next?  Thanks for your help.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck
URL: <http://cygwin.com/pipermail/cygwin/attachments/20071129/a30e1883/attachment.ksh>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list