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:
- Install Cygwin on the Windows server:
- I used RDP to connect to the server as the
Administratoruser - Used a web browser to access the installation instructions
- Downloaded the
setup-x86_64.exefile - 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:
cygrunsrvfrom theAdmingroupopensshfrom theNetgroup
- I used RDP to connect to the server as the
- After the Cygwin setup finished, I used the instructions found
here to configure and start the
sshdservice. This involved running the following commands in a Cygwin shell:ssh-host-config -ycygrunsrv -S sshd
- At this point, the
sshdservice 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 portsshdwas 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:
- To allow ssh access to other systems in our environment from the
Jenkins job, the necessary
sshkeys had to be installed in theAdministratoruser’s home directory. gitwas installed using the Cygwin installer.packerwas downloaded from the project’s download page and installed simply by placing the binary at the correct location.pvwas manually compiled and installed following the directions on the project’s website; i.e. using these commands:wget http://www.ivarch.com/programs/sources/pv-1.3.4.tar.bz2tar -xf pv-1.3.4.tar.bz2cd pv-1.3.4./configure --prefix=makemake install