Search A-Z index Help
University of Cambridge Home Physics Dept Home Mike Roses' Home Page TCM Group Home

Cygwin and sshd

Use the following steps to successfully get OpenSSH server working on a windows computer:

  1. Run (Open) the Cygwin Setup Program
  2. Disable Virus Scanner (you should be running one), "Install from Internet", local package directory somthing like C:\CygwinInstall, choose a suitable mirror (I like ftp://ftp.mirror.ac.uk).
  3. Now choose the packages you want to install. Click on the + sign next to "Admin" to expand it. Click on the word "Skip" next to the word cygrunsrv to install the NT/Win2k/XP Cygwin Service Initiator. Install cygwin-doc from "Doc", vim from "Editors" and openssh from "Net".
  4. After Setup is complete make sure that your virus scanner has restarted
  5. Since you're going to be running an internet service, you're definitely going to want to clean up your /etc/passwd and /etc/group files. You only want users that you want logging into your system defined in your /etc/passwd. In addition you only seem to need the SYSTEM user to be defined in your passwd file. If you have guest enabled and guest is defined in your /etc/passwd, people will be able to log onto your system without a password.
    mkpasswd -d -o 0 -u %userID% >> /etc/passwd will get the details for your domain user and put it into the passwd file.
    mkgroup -l >> /etc/group will create the local group file.
    Edit the /etc/passwd file to change the group ID of the user you have just added to a group in the /etc/group file. If you only want the user to be able to read things then put them in the None group. If you want them to able to do anything else then you will have to put them in the adminstrators group...... think before you do this.
  6. Now, you'll want to configure sshd. This is MUCH simpler than it used to be.
    Run ssh-host-config -y to set it up. This step will create necessary configuration files, a priviledge separation user and necessary directories. When prompted with "CYGWIN=" use the default "ntsec".
  7. You might want to change permissions and ownership on some files:
    • chmod og+w /tmp
    • chown system:system /var/log/sshd.log /var/empty /etc/ssh_h*
    • chmod 755 /var/empty
  8. Now you are ready to start the service: cygrunsrv -S sshd
  9. Test the service by running ssh localhost. You sould find that you will have "Cygwin SSHD" as a service in the Windows Services Console.
  10. sshd will not always start on Windows after a reboot. The fix for this is to write a windows bat file that stops and starts sshd on windows startup (use the Windows Task Scheduler):
    C:\cygwin\bin\cygrunsrv -E sshd
    C:\cygwin\bin\cygrunsrv -S sshd
    
    and set it to run at windows startup using the task scheduler. Windows Explorer -> Control Panel -> Scheduled Tasks
  11. Test that you can ssh from another computer

To build Cygwin setup.exe from source

setup.exe current release source code
cygwin source code