How to: Install Cygwin and configure SSH


While it is a bit "heavy" (weighing in at 190MB for base + SSH), Cygwin provides an up to date Bash 4.x shell along with an assortment of standard UNIX like utilities. This setup can help simplify the management of heterogeneous (Microsoft/Linux/*NIX) environments.

We have made good use of the SSH Functionality to standardize our QA test scripts across all our supported platforms.

This article aims to:

  • Walk through an install of Cygwin 1.7.5 (Base Packages + SSH)
  • Configure the Cygwin SSHD

Notes:

 

Install Cygwin:

  1. Download & Run the installer from cygwin.com
  2. When Prompted, select Install from Internet and hit 'Next'
  3. Leave the Root Directory and Install For settings at their defaults and hit 'Next'
  4. Change the Local Package Directory to c:\cygwin and hit 'Next'
    ..This helps keep the file system clean
  5. Pick your internet connection type. I get by with Direct Connection and hit 'Next'
  6. Pick a Mirror (The more you pick, the slower the install) and hit 'Next'
    ... I like to pick one that is geographically close by me.
  7. You may see a Setup Alert Message
    ... If this is the first time you are installing, just click OK
  8. On the Select Packages Screen, enter 'ssh' in the search bar
    Expand the Net Category
    Checkmark everything except for:
    .. libssh2: SSH2 protocol library (sources)
    .. autossh: Automatically restart SSH sessions and tunnels

    CygwinSSHPackageSelection.png

    Click 'Next'
  9. You will see a screen asking you to confirm you settings. Leave the 'Select required packages (RECOMMENDED) option checked and hit the 'next' button
  10. The Cygwin installer will download all the selected packages and install them.
  11. Click Finish to complete the installation

 

Configure SSHD:

  1. Open a cygwin terminal prompt
  2. run ssh-host-config
  3. When prompted, say "yes" to "Should privilege separation be used?"
  4. When prompted, say "yes" to "...create a new local account 'sshd'?"
  5. When prompted, say "yes" to "Do you want to install sshd as a service?"
    .. Note: Say No if cygwin is already installed
  6. When it asks "Enter the value of CYGWIN for the daemon" enter 'ntsec' (without quotes)
  7. When prompted, say "no" to "Do you want to use a different name?"
    ... Say yes if you want a different ssh user than cyg_server
  8. When asked, say "yes" to "Create new privileged user account 'cyg_server'"
  9. When asked, enter a password for the account.
    .. Note: This must meet the local security policy requirements for password

    The process should terminate
  10. To start the sshd service now (rather than waiting for restart) run:
    net start sshd

    Open a firewall exception for port 22 (to allow SSH to work) or disable the windows firewall
  11. Using a tool like putty, try accessing the server.
    .. When prompted about the servers host key not being cached, say 'yes'

    NOTE: Usernames are case sensitive! This surprised me the first time I tried to ssh into a windows box.