Installing Cygwin & the apt-cyg command

Cygwin, for me and many other *nix user, can make working in the windows environment bearable, at least once you have some stuff setup.

Here’s a short list of the procedure that I go through on every Windows box I use.

Installing Cygwin

The installation is just like any other Windows Wizard style installer, and it’s very simple to use.

All you need to to is download the installer fire it up and walk through the steps, but make sure to select a couple of things:-

Choose a decent mirror

The kernel.org mirror is throttled so it can take an absolute age to install anything.  Personally I just pick one that appears to be in Europe, it’s not that hard to tell from the TLDs.

Choose a few non-default packages

When you get to the step that allows you to select the packages you can select whatever you thing you might need, don’t worry too much at this point we can easily add more at a later date.

Make sure to select the subversionwget packages, we’re going to use them in a moment to setup and use a command line based installer.

At this point I also select openssh and mintty, as I want to access the windows box via ssh and mintty is a great replacement to the windows cmd.exe.

Once you have these selected continue through the installer, if you selected a good mirror it shouldn’t take more than a few minuets to finish installing.

Setup ssh Access

If you installed ssh you can get the service running by opening mintty, or just open the regular Cygwin command prompt, from the Start Menu – make sure to “Run As Administrator” so the ssh setup scripts has sufficient rights.  If it’s the first time you’ve used it it’ll setup your home and other defaults.

Now you can run ssh-host-config, you have 2 options here: 1 pass the -y flag which will install everything with the defaults; 2 don’t pass any flags and it’ll prompt for you for some information.

$ ssh-host-config -y

You’ll need to enter a password for the cyg_server user, just put one in you shouldn’t ever need it again.

Once it’s finished you can start the service, FYI the service has been set to start automatically so this is a one off command – you could do the usual Windows support action and reboot!

You can start it by issuing the following command :

$ cygrunsrv -S sshd

Or :

$ net start sshd

Before you can access the server you need to open port 22 on the Windows firewall.  This is simple enough, open “Windows Firewall” and then open “Advanced Settings”.  Select inbound rules, and add a “New Rule” select “Port”, 22,  give it a name and that’s it.

You can now connect to the machine via ssh.

$ ssh <ip/domain>

Once I have this access I rarely need to gain access to desktop.

Installing extra packages via apt-cyg

IMHO, one of the best features on *nix is the ability to install anything via the command line, and do it remotely over ssh.  If you have ever used Debian / Ubuntu you will have used Aptitude or apt, some cleaver sparks have brought the same functionality to Windows via Cygwin, apt-cyg.

This is why I said to install subversion, we’re going to use it to install apt-cyg, either use ssh or mintty on the desktop and issue the following commands.

$ svn --force export http://apt-cyg.googlecode.com/svn/trunk/ /bin/
$ chmod +x /bin/apt-cyg

And that’s it, you can now use the apt-cyg command to install additioanl Cygwin packages, for example vim is my editor of choice so I then issue :

$ apt-cyg install vim

From here on there’s no much difference between your *nix boxes and you Windows ones.

This entry was posted in Cygwin. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>