Running `sshd` on Windows using Cygwin

Introduction

As part of our effort to support Delphix in the Azure cloud environment, we’re writing some automation to convert our .iso install media into a VHD image, leveraging Jenkins and Packer in the process.

Essentially, we want to use a Windows server as a Jenkins “slave”, and run Packer from within a Jenkins job that will run on that Windows system.

In order to do that, the Jenkins “master” needs to connect with the Windows system, such that it can configure the system to act as a Jenkins slave. Additionally, due to some of our existing Jenkins infrastructure, this requires the Jenkins “master” using ssh to connect to the Windows box. Thus, sshd is needed on the Windows system.

Running sshd on Windows using Cygwin

The following is a quick run-down of the steps I needed to perform, to install and configure sshd on our Windows server, enabling ssh clients (and our Jenkins master) to connect to it:

  1. Install Cygwin on the Windows server:
    • I used RDP to connect to the server as the Administrator user
    • Used a web browser to access the installation instructions
    • Downloaded the setup-x86_64.exe file
    • Executed setup-x86_64.exe, and followed the setup instructions
    • When reaching the package selection screen of the setup wizard, I explicitly selected the following packages:
      • cygrunsrv from the Admin group
      • openssh from the Net group
  2. After the Cygwin setup finished, I used the instructions found here to configure and start the sshd service. This involved running the following commands in a Cygwin shell:
    • ssh-host-config -y
    • cygrunsrv -S sshd
  3. At this point, the sshd service was running, but the Windows server’s firewall was blocking incoming connections to port 22. So, I had to edit the server’s firewall rules to allow incomming connections on port 22 (the port sshd was running on). For this, I followed the instructions that I found here.

Installing Additional Software

In addition to installing Cygwin and running sshd, we also needed to perform a little more configuration to the Windows system, as our Jenkins job had these additional dependencies: