Thursday, April 7, 2011

Linux on Windows: CYGWIN

In order to setup a working linux environment on Windows try Cygwin. Cygwin is a implementation of a range of linux functions/functionality for Windows.

  1. Go to and download the setup file.
  2. Run the file by double click and choose "install from internet".
  3. When prompted I prefer to install Cygwin to "Program Files", which although warned about does not seem to give problems.
  4. When prompted for choosing packages choose:
    • Editors
      • emacs
      • mc
    • Net
      • openssh
      • rsync
  5. Finish the installation. 
  6. Run (double click) the shortcut on the desktop. It will create your home folder in the appropriate location (in this case (english WinXP) "C:\Program Files\cygwin\home\you").
  7. In the Cygwin window run "ssh" which will create the ".ssh" folder in your home folder.

Friday, February 11, 2011

Cygwin: Setting up a trusted ssh-relationship

If you are frequently connecting via ssh to the same server or if you are using rsync to backup your files as will be described in a later guide, you might want to set up a trusted relationship between your local computer and the remote server.

Start by generating a private/public key set.
Run the following command:
$ ssh-keygen -t rsa

Now go to your local .ssh folder.
Then download the "authorized_keys" file from the server
scp .
then make a backup copy of the file:
$ cp authorized_keys authorized_keys.backup
now merge public key into the authorized_keys file
$ cat authorized_keys
and upload the authorized_keys file to the server
$ scp authorized_keys

Now try and connect via ssh:
$ ssh
It should now not prompt for password.

NSLU2: When the power supply (PSU) dies ...

Problem: My NSLU2 has stopped working. Problem pinned down to being the power supply. The following description matches very well my experience, although my power supply worked 24/7 for 3 years (the first two supplying a 2.5' disc.:

"It showed an interesting mode of failure.... after being used for about 1 year 24/7, the LED still illuminated and the unloaded votlage was 5.0V (good) but when a Slug was switched on, the voltage dropped to about 3V and the Slug could not boot. The Slug's Power LED showed faint 'pulsing' in time with USB Memory stick access attempts (difficult to see with your finger over the Power button though). The power supply was binned. "

"It has been noticed that the supplied Linksys PSU appears to fail after about a year if supplying two USB powered 2.5" laptop drives from the NSLU2.Symptoms include, but not limited to hard drives not being mounted properly at boot time, although the slug will boot with no disks attached for a while until the supply dies completely." -

My solution:
I bought a "AC Power Adapter/Charger for PSP 1000/2000/3000" from Then I exchanged the plug that the Power Adapter/Charger came with the plug from the original NSLU2 PSU. When doing this, BE CAREFUL and use a voltmeter/multimeter to make sure + and - are connected correctly. Double double check, because you might end up destroying your NSLU2 if applying a wrong voltage.

I did all this, and my slug is again running like a charm.

Monday, February 7, 2011

Cygwin: Making a ssh connection with tunnels to your server

To make a ssh connection to a linux server, do the following:
Start by loading Cygwin: Start a cmd prompt and load Cygwin:
C:\folder>loadcygwin (the script is described here).

the run the ssh connect command:

This will prompt for your password before allowing the connecntion. Voilá!

If you want to take advantage of one of the strengths of ssh, namely the tunnels run the command as:
C:\folder>ssh -L 123:remotehost:456

which will open port 123 locally (on your computer/localhost) which is tunneled to port 456 on the server remotehost.

You can with benefit put this command into a batch (.cmd) file, such as the following ssh_server_com.cmd.


@echo off
echo Connecting ...
call loadcygwin.cmd

ssh -L1125:localhost:25

Cygwin: Setting up the environment and locale

When using Cygwin to connect to linux servers, and when using Cygwin in a windows environment in general, it is important to get the locale right.

I am using Cywin through cmd-sessions, and I load Cygwin manually for each cmd-prompt session, as I do not want to override the Windows/Dos commands by default.
Thus I run the file loadcygwin.cmd each time I want to switch to/load Cygwin.
The content of loadcygwin.cmd is listed below:


@echo off
call setcygwinenvironment.cmd
:: WinXp
set path=c:\Program Files\CygWin\bin;%path%
::set path=C:\Program Files (x86)\cygwin\bin;%path%
echo Cygwin now loaded.

In this file I am calling the script setcygwinenvironment.cmd which sets the locale. (As you can see I am living in Denmark, which my locale settings reflect)


echo Setting up CYGWIN environment...

:: Set cygwin locale to the same as windows locale.
set LANG=da_DK-UTF-8
set LC_CTYPE=da_DK.UTF-8
set LC_TIME=da_DK.UTF-8
set LC_ALL=da_DK
set CYGWIN=acl nodosfilewarning
echo done.