Configuring Cygwin on a Windows server

After Cygwin is installed, you must configure CYGWIN sshd to run as an automatic service, start the service, and update Cygwin environment user accounts and groups for users to log in to the remote server on the Windows system.

Procedure

To configure your Cygwin environment to work correctly with the workbench, complete the following steps:

  1. Right click My Computer, and click Properties > Advanced > Environment Variables to modify the PATH variable and to create a new environment variable. In either the User or System variables section (use the System variables if any account using this computer can use Cygwin):
    1. Select the PATH variable, click Edit, and append ;c:\cygwin\bin to the end of the existing variable string.
    2. Click New to add a new environment variable that is named CYGWIN. In the Variable name text box, enter CYGWIN, and in the Variable value text box, enter binmode tty ntsec.
    3. Save the changes by clicking OK until the My Computer window closes.
  2. Start Cygwin. You can double-click the shortcut on your desktop if one was created when you installed Cygwin. A command window is opens.
  3. Run the ssh-host-config command by typing ssh-host-config after the $ prompt. By default, privilege separation is set to Yes when OpenSSH 3.3 or newer versions are used. You can specify No to the privilege separation option and set the service to allow public key authentication that uses the sshd-server account.
    Respond to the prompts that are displayed as follows:
    1. When you are asked Query: Should privilege separation be used?, enter the appropriate response based on your environment:
      • Enter yes to create an unprivileged user.
      • Enter no to use the sshd-server account.
    2. When you are asked Query: Do you want to install sshd as a service?, enter the appropriate response based on your environment:
      • Enter yes to install sshd as a service.
      • Enter no if sshd is already installed as a service.
    3. When you are asked Query: Enter the value of CYGWIN for the daemon: [ntsec], enter ntsec tty.
  4. Start the sshd service. In a Windows command prompt, type net start sshd or, in a bash prompt, type cygrunsrv -start sshd. To verify that the sshd service is running, you can type ps –a and check that /usr/sbin/sshd is in the list of running processes, or you can click Control Panel > Administrative Tools > Control Services to do this checking.
    To stop the service, in a Windows command prompt, type net stop sshd. Alternatively, you can change to the C:\cygwin\bin directory (or open a bash shell) and type cygrunsrv -stop sshd.
  5. After start the service, test the service by entering the following information from a bash prompt: ssh localhost -l your_username. If you are informed that the authenticity of localhost cannot be established and are asked Are you sure you want to continue connecting?, enter yes. When you are prompted for your account password on localhost, enter the password that you use when you log on to the computer.
  6. Verify that the Cygwin sshd service has been added as a service that starts automatically. To complete this verification, click Start > Settings > Control Panel > Administrative Tools > Services.
    You might get the sshd/cygrunsrv service error when you try run the service.
    cygrunsrv: Error starting a service:
    QueryServiceStatus: Win32 error 1062:
    The service has not been started.

    This is because you might have an old or corrupt installation of Cygwin.

    To resolve the issue, try reinstalling or run the following command:
    cygrunsrv -R sshd
    REBOOT (or use the Task Manager to kill all instances of sshd that may be running in the background)

    Run ssh-host-config -y again.