Setting Up SSH Keys to Connect from Windows to a Linux Server with Putty

The following is a how to on getting putty set up putty on a Win XP box to enable you use an RSA (or DSA) private/public key pair to connect to a linux server over SSH.

  • Generate your keys on the linux server to which you want to connect.
  • SSH to your server
  • go to your home directory .ssh/
  • Enter the following command to generate the key pair:
  • # ssh-keygen -t rsa
  • Enter a passphrase for your keys

This will generate two files: id_rsa and id_rsa.pub. id_rsa is the private key.
Transfer the id_rsa file to your client/local machine. Delete the id_rsa file from the server.
Use puttygen.exe to convert the private key to a format that putty.exe will like

  • Fire up puttygen.exe
  • Select File/Load Private Key
  • Enter your passphrase that you entered when generating your key pair
  • Click on the “Save Private Key” button to save a format of this private key to your local drive.

Open putty.exe

  • By default putty.exe starts with the “Session” screen selected.
  • Click on Connection/SSH/Auth
  • Under “Private key file for authentication” click on “Browse” and select the private key that you converted in the aforementioned step.
  • Go back to the Session screen, specify the IP address or name of your server and save the session.

Connect to the server:

  • Run putty.exe
  • Simply double-click on the saved session and it will open up an SSH session to your server and you will be prompted to enter your passkey.

Java In-line Initialization of a Map in the Constructor of an Enum Constant

With Java 5.0 enums became much more powerful, click here for an overview.

I am working on a project that is using an enum to keep track of an attribute of one of my objects and wanted to initialize a HashMap inline in the call to the enum’s constructor. Such was my delight to find out that using a simple initializer block that it was a snap.

Here is the relevant snippet of code that illustrates the syntax:

public enum MediaFileType{
    IMAGE( new HashMap<String, String>() {
            {
                put(“.jpg”, “image/jpeg”);
                put(“.jpeg”, “image/jpeg”);
            }
        } );

Open-Source JavaScript Flash Player (HTML5/SVG)

This is quite incredible. A purely Javascript Flash Player. Here are some examples.

I think that projects like this are simply proof that the days of Flash and it’s plugin based virtual machine in a browser are numbered. Along with jQuery and a host of other Javascript frameworks that are being built, once HTML 5 browsers are in the majority there will be many more options for multimedia content/interactivity on a page than Flash.

Compiling a 64 bit version of SWT for Eclipse

On the SWT FAQ there is a how-to for compiling a 64 bit version of SWT for Eclipse, however, it is currently incorrect and took a bit of research and experimentation to sort out.

Here is how to do it (I have copied the original how-to and made edits where appropriate.

In this case, I am using Eclipse 3.5.1 under Kubuntu 9.04.

In this how-to you will extract the SWT source from the CVS repository and build your own binaries.

  1. Start Eclipse and retrieve the org.eclipse.swt, org.eclipse.swt.gtk.linux.x86_64 and org.eclipse.swt.tools projects from dev.eclipse.org (see How to use SWT from CVS)
  2. In the org.eclipse.swt project rename tthe .classpath_gtk to .classpath.
  3. Convert SWT’s Java and C code from its 32-bit form to 64-bit:
  1. To convert the Java code in-place, open the build.xml ant script with Ant in the org.eclipse.swt project and run its “replace.32.to.64” target. Simply click on it to highlight it and then click on the “Run the Selected Target” button in Ant. Once this target has completed you must refresh (F5) the org.eclipse.swt and the org.eclipse.gtk.linux.x86_64 project in order to pick up the changes.
  2. To convert and build the C code, run the “build_natives” target in the same build.xml file. Refresh (F5) the org.eclipse.swt.gtk.linux.x86_64 project when this target has completed, to pick up the new libraries.
  3. Make sure to add the new compiled source library to your build path:
  1. Click on your project node in the Package Explorer.
  2. Right click on it and select “Link Source”.
  3. Browse to the org.eclipse.swt.gtk.linux.x86_64 directory and select it.
  4. Add all of the items in it.

An Excellent Primer on Both Programming and Java

Introduction to Programming Using Java, Fifth Edition Version 5.0, December 2006

David J. Eck also provides the source code to a TextIO class that he has written that provides some additional IO features.  Click here for an outline of those methods and on that page is also a link to the source.