18 October 2009
Cywin provides a Linux like environment for Windows. Basically it ports the command shell and some GUI and non-GUI applications to windows. It's most useful for allowing shell scripts to run in a command line on windows, or running system services such as SSH.
Note that cygwin is not an emulator, it doesn't run binaries taken from Linux, but instead allows applications to be recompiled to run on Windows. This doesn't mean that you have to recompile the applications yourself as many are available as part of the setup process.
The setup.exe program file is available from the Cygwin website. You can run the setup program direct from the website or download it first. The setup file
allows you to choose an appropriate repository to download the packages from, and then provides a list of applications which can be installed. You pick which applications you want installed and then it goes through downloading and installing the relevant applications.
If you want to install new applications at a later date, then you go to the website and run the setup programme again (or access the previously saved version).
SSH is a network protocol that allows you to logon using a command line and / or transfer files. This is like telnet and ftp rolled into one, but it's a lot more secure and has a lot more features. Some of the things you can do with ssh are listed:
These make ssh a extremely versatile and very useful program. There are commercial and non-commercial applications designed around the ssh protocols. The more useful of these is OpenSSH
which is freely available. For more details, and information on how to configure / use the above features visit www.openssh.org.
By installing ssh on windows it allows files to be transferred easily and safely between windows and unix/linux machines.
Openssh can be installed using the Cygwin setup.exe programme, if you select the autossh package then the other required packages will be added to the install. Once installed there are however a few additional steps needed, particularly if you want to be able
to use the windows machine as a server as well as a client.
After installing the packages the ssh client will be installed in the /bin directory and the ssh server in the /usr/sbin directory. The ssh client can be setup by running /bin/ssh-user-config if you choose yes for all the options then it will setup keys that can be used for key authentication. Entering a complex passphrase key will make these secure, or leaving them blank can potentially allow loginng in to another machine without needing a password.
$ ssh-user-config Shall I create an SSH1 RSA identity file for you? (yes/no) yes Generating /cygdrive/c/Documents and Settings/swatkiss/my documents/.ssh/identity Enter passphrase (empty for no passphrase): Enter same passphrase again: Do you want to use this identity to login to this machine? (yes/no) yes Adding to /cygdrive/c/Documents and Settings/swatkiss/my documents/.ssh/authorized_keys Shall I create an SSH2 RSA identity file for you? (yes/no) (yes/no) yes Shall I create an SSH2 RSA identity file for you? (yes/no) (yes/no) yes Generating /cygdrive/c/Documents and Settings/swatkiss/my documents/.ssh/id_rsa Enter passphrase (empty for no passphrase): Enter same passphrase again: Do you want to use this identity to login to this machine? (yes/no) yes Adding to /cygdrive/c/Documents and Settings/swatkiss/my documents/.ssh/authoriz ed_keys Shall I create an SSH2 DSA identity file for you? (yes/no) (yes/no) yes Generating /cygdrive/c/Documents and Settings/swatkiss/my documents/.ssh/id_dsa Enter passphrase (empty for no passphrase): Enter same passphrase again: Do you want to use this identity to login to this machine? (yes/no) yes Adding to /cygdrive/c/Documents and Settings/swatkiss/my documents/.ssh/authoriz ed_keys Configuration finished. Have fun!
To allow connections to be made to the windows machine run the /bin/ssh-host-config script. This will ask if you want to install it as a service. This is required if you want it to be available whenever windows is started.
$ /bin/ssh-host-config Generating /etc/ssh_host_key Generating /etc/ssh_host_rsa_key Generating /etc/ssh_host_dsa_key Generating /etc/ssh_config file Privilege separation is set to yes by default since OpenSSH 3.3. However, this requires a non-privileged account called 'sshd'. For more info on privilege separation read /usr/share/doc/openssh/README.privsep . Should privilege separation be used? (yes/no) no Generating /etc/sshd_config file Added ssh to C:\WINNT\system32\drivers\etc\services Warning: The following functions require administrator privileges! Do you want to install sshd as service? (Say "no" if it's already installed as service) (yes/no) yes Which value should the environment variable CYGWIN have when sshd starts? It's recommended to set at least "ntsec" to be able to change user context without password. Default is "ntsec". CYGWIN= The service has been installed under LocalSystem account. To start the service, call `net start sshd' or `cygrunsrv -S sshd'. Host configuration finished. Have fun!
If you have either a hardware or software firewall you may need to change it to allow logins to ssh. The logins connect to port 22 which may need to be added manually.
After installing the server you can just use the command line client to connect to other servers. In it's most basic form:
ssh machine2.mydomain.comwill login to machine2.mydomain.com interactively using the same username as you are currently logged in as. There are however a number of GUI applications that can be used: