Setting Up the SSH Server

The SSH server, sshd, runs under Cygwin as a standard Windows service, called (not surprisingly) Cygwin SSH Service. Cygwin provides a script, called ssh-host-config, to set this up. Here’s what to do:

Warning

The Cygwin SSH Service (a.k.a. sshd) runs only on flavors of Windows that support services: NT, 2000, XP, 2003, etc.

  1. Make sure you’ve set up the path and environment variables for OpenSSH and Cygwin. [14.1]

  2. From an account with administrative privileges, run:

        C:\> ssh-host-config
  3. Answer yes to all questions.

  4. When ssh-host-config completes, your service should be ready to run. Open your Services control panel, look for Cygwin SSHD Service, and start the service. Alternatively, use the command line:

        C:\> net start sshd

    You might also want to set the service startup to Automatic, so it runs whenever you boot the computer. To stop the service, again use the Services control panel or type:

        C:\> net stop sshd

If the service refuses to run, here are some things to try:

  • Make sure the file /var/log/sshd.log is writable by the SYSTEM account.

  • Read /var/log/sshd.log for error messages.

To test the server, connect to yourself:

    C:\> ssh localhost

You should be prompted for your password and be able to log in.

Tip

Serverwide configuration files are found in /etc, such as /etc/sshd_config. This is in contrast to Unix-like systems that usually keep these files in /etc/ssh.

14.3.1 Opening Remote Windows on the Desktop

If you want to run graphical applications via ssh that open windows, ...

Get SSH, The Secure Shell: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.