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:
- Download & Run the installer from cygwin.com
- When Prompted, select Install from Internet and hit 'Next'
- Leave the Root Directory and Install For settings at their defaults and hit 'Next'
- Change the Local Package Directory to c:\cygwin and hit 'Next'
..This helps keep the file system clean - Pick your internet connection type. I get by with Direct Connection and hit 'Next'
- 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. - You may see a Setup Alert Message
... If this is the first time you are installing, just click OK - 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
Click 'Next' - You will see a screen asking you to confirm you settings. Leave the 'Select required packages (RECOMMENDED) option checked and hit the 'next' button
- The Cygwin installer will download all the selected packages and install them.
- Click Finish to complete the installation
Configure SSHD:
- Open a cygwin terminal prompt
- run ssh-host-config
- When prompted, say "yes" to "Should privilege separation be used?"
- When prompted, say "yes" to "...create a new local account 'sshd'?"
- When prompted, say "yes" to "Do you want to install sshd as a service?"
.. Note: Say No if cygwin is already installed - When it asks "Enter the value of CYGWIN for the daemon" enter 'ntsec' (without quotes)
- 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 - When asked, say "yes" to "Create new privileged user account 'cyg_server'"
- When asked, enter a password for the account.
.. Note: This must meet the local security policy requirements for password
The process should terminate - 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 - 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.