Load an EC2 GUI on Your Mac OS X Box
Using straight shell access on EC2 servers works just fine, of course, but there are images available that include the full desktop environment. If you use one of those, you can activate GUI programs on the EC2 server. Now you can't plug a monitor into your EC2 instance, so you will need to tunnel the GUI bits down to your local box. Luckily, Unix pretty much just handles all of this for you and if you can SSH into an EC2 instance and you have Apple's X11 installed, you are all set to try this.
I know at one time Apple's X11 environment was an optional install. I can't remember if it still is, but you can see if you have it by looking for a program called X11 in
/Applications/Utilities/. Or, just fire up a Terminal and enter the command
xterm. If a rather plain white shell window eventually appears, you are in business. If you do need to add the optional install, it should be on the disk that came with your computer (or the OS install disks).
Once you've confirmed X11 is ready, you need to fire up an EC2 instance. Create a Key Pair and configure a Security Group to at least allow SSH access. Then just launch an EC2 instance (I use the AWS Managment Console for that) with the needed desktop environment tools. I chose one of the wonderful Ubuntu Images by Eric Hammond.
Once the instance is running you are past all the hard parts! All that's left is to connect to the instance, with a few more options than you probably use normally. Here's the full command:
ssh -X -C -c blowfish -i KEY_FILE_PATH -l root INSTANCE_PUBLIC_DNS
KEY_FILE_PATH with the path to the
.pem file Amazon had you download while creating your Key Pair. Also replace
INSTANCE_PUBLIC_DNS with the address listed as Public DNS in the AWS Management Console for the instance you launched.
Just FYI, here are the meanings of all the switches I used:
-Xis the magic switch that turns on X11 forwarding
-Cactivates compression, which usually speeds up GUI interactions
-c blowfishswitches to a faster encryption method, for even more speed
-i …allows you to specify your identity file
-l …allows you to specify your login (which a lot of people prefer to add to the front of the server address with an
@between the two)
When you're done playing around and plan to use an instance long term, I recommend creating a user, switching your
-l username to that identity, and uploading your standard public key so you can drop the
-i switch altogether. That's all work though and we're just trying things out here.
Enough setup, let's get to playing! Want to browse the instance files using a GUI browser? This command will launch Nautilis:
nautilus --no-desktop --browser
Need to download something to the instance? You could
wget the URL or you can just launch Firefox and browse normally:
You get the idea.
Avoid the Mac conventions of going after a
Quit command in the menus. That will shutdown all of X11 and not just the current program. Instead, close the window of the program you wish to stop and your SSH session should give your prompt back.
I also seem to need to kill my SSH session (with a control-C) after I've been using GUI applications, even though I logout normally. I'm not sure why that is.