Cygwin is a Windows program that emulates a Linux like environment for your Windows PC, it is easy to install and provides modular approach to adding tools to the environment. The key to Cygwin working is the cygwin1.dll that gets installed, it provides a Linux API emulation layer for the applications that are specifically compiled for the Cygwin environment.
For more in-depth information into how the Cygwin application works see Cygwin
This article some key setup tips and how to configure what I find one the the most useful aspects; the SSH server with Cygwin.
Cygwin Tools in Windows Command Prompt
All of the default tools provided with Cygwin are very useful, however I did find my self trying to use Windows tools whilst in Cygwin and Linux tools whilst in Windows!
To solve this simply add the Cygwin bin folder (C:\cygwin\bin) into your Windows Path environment variable and there you go. From a command prompt you can use both the dir or ls commands depending on your mood.
Right Click on My Computer then select Properties
Choose Advanced then Environment Variables
Under System variables edit the variable Path and add the Cygwin bin folder,
i.e. ;c:\cygwin\bin
Setting-up SSH Access
When accessing you Windows PC remotely, it only supports full GUI access or unencrypted Telnet traffic. With Cygwin you can install the OpenSSH server which is an open source SSH connectivity tool supporting various well known featured including both SSH1 and SSH2 protocols.
The implementation below explains how to setup OpenSSH through Cygwin which will run a service on your Windows PC called CYGWIN sshd
Re-requisites required
When authenticating to your PC via SSH it will use the existing Windows user accounts to authenticate, the user account that you want to use must have a password set.
Ensure that Cygwin is installed along with the package called openssh
Add Environment Variables
Right Click on My Computer then select Properties
Choose Advanced then Environment Variables
Under System variables click New with the name of CYGWIN and a value of ntsec
Under System variables edit the variable Path and add the Cygwin bin folder, i.e. ;c:\cygwin\bin NB do not do this part again if you have already in the previous post.
SSH Host config
Open a Cgywin console and run command
ssh-host-config
When prompted, answer the following:
Privilege Separation answer yes
Create local user sshd answer yes
Install SSHD as a service answer yes
CYGWIN= answer ntsec
NB: The ntesc answer tells Cygwin to authenticate using the local Windows accounts
Start the SSH service to allow connections
The Windows service will default to start automatically every-time Windows starts, to start the service manually run one of the two commands
net start sshd
or
cygrunsrv –start sshd
Synchronise local Windows user information with Cygwin
Run the two commands from within Cygwin
mkpasswd –local > /etc/passwd
mkpasswd –group > /etc/group
Testing SSH Works
Use a SSH client such as PuTTy and then connect to localhost on port 22 (SSH Port)
Alternatively use the Cygwin SSH client:
cygwin# SSH user@localhost
NB: The port used by OpenSSH can be changed in the file c:\cygwin\ssh-host-config under port_number. After changing the port number you must re-start the CYGWIN sshd serivce for changes to come into effect.