Remotely managing your Server Core using SSH

Reading Time: 6 minutes

In the last few months I used my blog to post information on remotely managing your Server Core installations of Windows Server 2008 with numerous tools, including the Computer Management MMC Snap-Ins (compmgmt.msc), the Remote Server Administration Tools (RSAT), Remote Desktop Connection (using RDP) and Windows Remote Shell.

Now it's time to go a little further into uncharted territory and manage Server Core using PuTTY over SSH.

Tools

I'll be setting up OpenSSH on a x86 version of a Server Core installation of Windows Server 2008 Standard. To install it I'll simply use Cygwin package 1.5.25-15, which can be downloaded from the Cygwin Website On the client level I'll use PuTTY 0.60, which can be downloaded from the PuTTY Download Page for free.

In the table below are the versions of the tools used:

Tool Version
Cygwin installer 2.573.2.2
OpenSSH 5.1p1-3
DiffUtils 2.8.7-1
PuTTY 0.60

 

 

Server side configuration

Download Cygwin

To install Cygwin you can use the Installation Wizard (setup.exe) from the website.
It weighs 405 KB.

This Installation Wizard was previously available as a FTP download, but recently the Cygwin people decided to stick with website hosting only, allowing the program to retrieve the files and packages it needs using FTP. This step makes installing Cygwin on a Server Core installation slightly more difficult, because you now need a browser to download it.

On the other hand it offers the ability to combine the Installation Wizard and the necessary packages on a different host than your Server Core installation, which might be useful when your Server Core box can't access the Internet or you want to deploy loads of SSH servers to manage your Server Core boxes and don't want to strain your Internet connection too much.

Get the Cygwin installer on your Server Core

After you've downloaded the Cygwin Installation Wizard you need to transfer the file to your Server Core installation. You can use various methods, including: (but not limited to)

  • Copying the file to a USB or other portable rewritable media
  • Burn the file onto a CD or DVD media
  • Convert the file to a ISO file and mount it on your Server Core box (using DRAC/ILO)
  • Place the file on a SMB File Share and map a drive to it on your Server Core box
  • Place the file on an internally available FTP Server and grab it using ftp.exe.

Run the software installer

To start the installation change your prompt to the directory where setup.exe resides and type setup.exe. The Installation Wizard should appear. Perform the following steps:

  1. In the Cygwin Net Release Setup Program screen, which serves as a Welcome screen press Next >.
  2. In the Choose a Download Source select the Install from Internet (downloaded files will be kept for future re-use) option. When you have previously used the Download without Installing option to leech the 16 MB needed for OpenSSH and other utilities and distributed these files with setup.exe you can specify the Install from Local Directory option. Press Next >.
  3. In the Select Root Install Directory screen type a directory to install Cygwin in, or accept the default location of C:\Cygwin. Under Install For verify All Users is selected. Under Default Text File Type verify Unix / binary is selected.
    Press Next > when done.
  4. When you've selected to Install from Internet (step 2) specify the Local Package Directory on the Select Local Package Directory screen where you want the Cygwin Installation Wizard to store the installation files it downloads. Afterwards press Next >.
  5. In the Select Your Internet Connection screen choose from Direct Connection and Use HTTP/FTP Proxy to best describe your connection to the Internet and press Next >.
  6. In the Choose A Download Site screen select a mirror site close to your location to download the remainder of the setup files from. Check the Cygwin Mirror Sites page for more information on the mirrors. Press Next > when done.
  7. In the Select Packages screen open the Net category and scroll down until you reach the openssh: The OpenSSH Server a… entry. Click on the Skip button thingy in the second column to change it. OpenSSL will be installed automatically as well, which is fine. Also open the Utils category and scroll down until you reach the Diffutils. Install these. Press Next >.
  8. When you receive a window stating you also need to download a couple of packages your packages depend on (dependencies) choose the recommended setting to install these and press Next >.
  9. Wait for the Cygwin Installation Wizard to download the necessary packages. Wait a little longer for the Cygwin Installation Wizard to install the programs. In the Create Icons screen deselect the Create icon on Desktop and Add icon to Start Menu options. We won't be needing them. Press Finish when done.

I noticed my Server Core box downloaded 16,5 MB from the mirror website.

 

Configure OpenSSH

Type the following command in the folder where you installed Cygwin (refer to step 3) and run the following command:

Cygwin.bat

On the first run this will make Cygwin perform a couple of basic steps regarding the skeleton files before it will display its prompt. On the prompt type the following commands:

chmod +r /etc/passwd
chmod +r /etc/group
chmod 755 /var
ssh-host-config

Answer the following questions:

Question Answer
Should privilege separation be used? yes
Should this script attempt to create a new local account 'sshd'? yes
Do you want to install sshd as a service? yes
Enter the value of CYGWIN for the deamon : [ntsec] ntsec
Do you want to use different name? no
Create new privileged user account 'cyg_server'? yes
Please enter the password: Any Password*
Reenter: Any Password*

* these two values should meet the password complexity requirements.

You should receive the message when done:

*** Info: Host configuration finished. Have fun!

Create a Firewall exclusion

The Installation Wizard will not create a firewall exception by default, so you need to make one yourself. Use the following command to do so:

netsh advfirewall firewall add rule name="OpenSSH Server"  protocol=TCP dir=in localport=22 action=allow

 

Start the OpenSSH Server

The last step on the server is to start the Open SSH Server, by typing:

net start sshd

Note:
The CYGWIN sshd service is set to start automatically every time you reboot. You will only have to type the above command once. Alternatively to typing the command you could restart your Server Core box.

 

 

Client side configuration

On the intended client download a SSH client. PuTTY is by far the most popular SSH client. It is a Graphical SSH client for Windows and the best thing it's free.

Installing PuTTY

After installing and configuring OpenSSH on your Server Core installation you might suspect installing PuTTY on Windows is tricky as well, but it isn't. Technically you can't even install PuTTY: you simply download PuTTY and store putty.exe somewhere. (I've placed putty.exe on my desktop for easy access.)

Running PuTTY

To run PuTTY simple double-click it.

Note:
When you've downloaded putty.exe with Internet Explorer and stored it on a NTFS formatted drive you might get a Security Warning. To disable this warning right-click on putty.exe and open its properties. At the bottom of the General tab you'll find a button labeled Unblock next to the text "This file came from another computer and might be blocked to help protect this computer." Pressing the Unblock button will remove the text, the button and the Security Warning.

Connecting with PuTTY

To connect to your Server Core installation of Windows Server 2008 type the IP address or DNS name of your Server Core box in the Host Name (or IP address) field of the PuTTY Configuration Screen and press the Open button.

Log in with your credentials and presto!

 

 

Concluding

I hope this post helps you to connect to your Server Core boxes using SSH. It sure helped me convince a Linux minded firewall administrator to grant me access to one of my boxes, using the "I'm using all the right tools here" argument. Sometimes communication can be so much fun…

Although this post is only a brief exploration of SSH on a Server Core installation of Windows Server 2008, limitless options exist to manage your boxes using SSH tunneling.

When managing Server Core installations of Windows Server 2008 using SSH in an Active Directory environment, be sure to check out the documentation over on Port25.

Further reading

Setup an SSH Server in Vista
PuTTY Download Page
How to install OpenSSH on Windows 2000, XP or Vista
Installing OpenSSH for Windows 2003 Server – How to get it working
How to setup the secure shell daemon on a Windows 2003 server
Vista Blocked File Protection Control
OpenSSH with Kerberos and Active Directory
Port 25: OpenSSH on Linux using Windows/Kerberos for Authentication
Stupid SSH Tricks: Some Essentials
How to setup the secure shell daemon on a Windows 2003 server
ssh, Cygwin, and Samba
NT Security and usage of ntsec

 

Considerations

Updates

This blogpost endorses open source products. Open source products need patching. Patching OpenSSH on Windows Server 2008 requires manual interaction. You can use the Cygwin installer to update the open source packages installed. Please update your operational procedures to check for updates regularly. More information can be found in the Further reading section above.

Security

The version of OpenSSH used in this post offers both version 1 and version 2 of Secure Shell. (SSH1 and SSH2) SSH1 has inherent design flaws which make it vulnerable to, e.g., man-in-the-middle attacks, it is now generally considered obsolete and should be avoided. For security considerations you should disable SSH1 in the sshd_config file. More information can be found in the Further reading section above.

leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.