Setting up Cygwin SSH server

Introduction

"Cygwin is a distribution of popular GNU and other Open Source tools running on Microsoft Windows. The core part is the Cygwin library which provides the POSIX system calls and environment these programs expect." - Official Cygwin homepage.

Deploying CDP applications to Windows machines is possible only if a Cygwin SSH server is running on the target machine and Rsync is available. This tutorial gives step-by-step instructions on how to set it up and how to configure the target environment.

Setting up Cygwin and SSHD

Download Cygwin

Download the appropriate version of Cygwin and save it somewhere on the target system. Click here to go to Cygwin download page

Install Cygwin

  • Run the Cygwin installer
  • Using all the default installation options go through the installation wizard until package selection page is presented.
  • On the Select Packages page use the search bar to locate openssh, openssl and rsync packages under subsection All->Net. Clicking on the little refresh button of the package select the latest versions for both of the packages and click Next
  • Finish the installation

This process installs a Cygwin terminal and the necessary files for setting up an SSH server.

Configure SSH Server

  • Run the Cygwin terminal as administrator
  • Type in the following command: ssh-host-config

You are prompted with some or all of the following questions:

*** Query: Overwrite existing /etc/ssh_config file? (yes/no) yes

*** Query: Overwrite existing /etc/sshd_config file? (yes/no) yes

*** Query: Should StrictModes be used? (yes/no) no

*** Query: Should privilege separation be used? (yes/no) yes

*** Query: new local account 'sshd'? (yes/no) yes

*** Query: Do you want to install sshd as a service?

*** Query: (Say "no" if it is already installed as a service) (yes/no) no

You should then be prompted with text saying that the host configuration was successful.

Start SSH Server (SSHD)

SSH server should be run as a user process invoked via Windows startup system (at user logon). If SSH server is run as a service or under user not currently logged into, then CDP GUI applications can not be shown. To run SSH server on Windows startup follow these steps:

  • Go to "C:\Users\<USER NAME>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" or press Windows key + R, type shell:startup and select OK.
  • Create a shortcut for the command C:\<CYGWIN INSTALL DIR>\bin\bash.exe --login -c '/usr/sbin/sshd'
  • Restart Windows

After restart SSH server should be started as a background process and be ready for usage.

Note: If you had Cygwin already installed make sure you disable all SSH services that may collide with our setup.