I recently had the exciting opportunity to give Amazon EC2 a spin and as a first-time Linux-experiment, I opted to use Clint Pells' Ubuntu Feisty image with an aim to set up Ruby on Rails and some other goodies.
Coming from a Windows background, and having been spoiled with fancy GUI tools, the SSH terminal access felt somewhat intimidating, so I wanted remote-desktop-like connectivity to my EC2 instance. The following instructions outline the exact steps to connect to your EC2 Ubuntu image via VNC from your Windows Machine. At the time of writing, my knowledge of Linux systems is limited to the 5 hours I spent mucking around with my installation, so I am writing this tutorial for fellow developers that need a no-nonsense step-by-step guide.
RequirementsFirst, this is what you will need:
- A running instance of the Ubuntu Feisty AMI (ami-898560e0)
- Putty SSH client on your Windows machine that is connected to your instance
- TightVNC Viewer on your Windows machine
Getting Your Hands Dirty
1. Make sure Ubuntu is updated
This is simple; type this in from your terminal:
sudo apt-get update
2. Install the Desktop Environment
The Ubuntu image that we are using does not have a Window manager, so we need to install this first on the server. This may take a while since it needs to be downloaded. In your terminal, type in:
sudo apt-get install x-window-system-core xserver-xorg gnome-desktop-environment
3. Install TightVNC Server
Next, we install the VNC server that we will be using.
sudo apt-get install tightvncserver
At one point, this will show a screen asking you to select screen dimensions, but I was content with the default options and just hit continue.
4. Launch the server
First we run VNCServer to set the password (I know you are probably lazy, but make it a $tR0nG password). In your terminal, type in:
Next, set up a session ... By default, port :0 corresponds to port 5900, :1 to 5901 etc. Remember that no 'firewall configuration' is necessary since we will be using a SSH tunnel for security.
This returns a message similar to New 'X' desktop is domU-XX-XX-XX-XX-XX-XX:1
5. Configure SSH Tunnel in Putty
Close down your SSH session and open Putty again. Under Category, go to Connection>SSH>Tunnels. In Source port, put 5901; in Destination, put your instance DNS name followed by :5901 i.e. ec2-XXX-XXX-XXX-XXX.z-2.compute-1.amazonaws.com:5901
6. Connect with VNCViewer
Open TightVNCViewer, and type in localhost:1, then hit OK. Then type in the VNC server password that you created in step 4. Once it launches, it may look crummy and ugly. If this is the case, it is because you didn't use the VNCViewer for fast compression. Next, you will notice a command screen but nothing else. DON'T PANIC! - I didn't set you up. Just type:
This will bring up the desktop environment and display a list of errors that you can ignore.
7. IMPORTANT: Shutting down your session
Lastly, you will need to know how to shutdown the VNCServer Session that you created. Simply type in the following from your SSH command prompt:
vncserver -kill :1
You are now Golden
You are now ready to access your EC2 instance securely and easily. Until next time ...