Installing a graphical desktop to Ubuntu on Amazon EC2

Amazon’s EC2 service offers an interesting diversity of cloud computing. From less than a dollar an hour, you can run a powerful virtual machine on their hardware. View my previous post on setting up an Ubuntu machine with R.

I was interested in playing some with this infrastructure, and now installing a graphical interface, GNOME, on a Ubuntu machine. After setting up an Ubuntu 10.10 machine from these instructions, set up remote access with these instructions:

1. Install ubuntu desktop

export DEBIAN_FRONTEND=noninteractive

sudo -E apt-get update

sudo -E apt-get install -y ubuntu-desktop

2. Install FreeNX server on your server

sudo add-apt-repository ppa:freenx-team

sudo sed -i ‘s/maverick/lucid/g’ /etc/apt/sources.list.d/freenx-team-ppa-maverick.list

sudo apt-get update

sudo aptitude install -y freenx

The freenx server is from Lucid, but it works on Maverick, however it is missing the setup script, download it using wget:


tar -xvf nxsetup.tar.gz

And install:

sudo cp nxsetup /usr/lib/nx/nxsetup

sudo /usr/lib/nx/nxsetup –install

When it asks you:

It is recommended that you use the NoMachine key for
easier setup. If you answer “y”, FreeNX creates a custom
KeyPair and expects you to setup your clients manually.
“N” is default and uses the NoMachine key for installation.

Enter “N”

3. Enable password authentication

sudo vi /etc/ssh/sshd_config

edit the line:

PasswordAuthentication no

change it to

PasswordAuthentication yes

Then, enter:

sudo /etc/init.d/ssh restart

Then, set a password for the user ubuntu:

sudo passwd ubuntu

4. Install the client on your machine:

Download the NX client for your machine from

Run the client and enter on the host address field, your server’s address, then, on the next window, select UNIX and GNOME. The client will ask you for the username and password (ubuntu and the password from step 3).

This will use most of the screen. If you want to run it in a smaller size, click on “Configure…” and change the Display settings:

Click OK, then Login.

Once you are logged in, you will be able to see the GNOME desktop:

When you start a new instance from an AMI that already has NX installed, it won’t work. You’ll have to purge it and reinstall it, but it takes a few seconds:

sudo apt-get purge freenx*

sudo apt-get autoremove

sudo apt-get install freenx*

sudo /usr/lib/nx/nxsetup –install

From these sources:

This entry was posted in Cloud Computing, Ubuntu. Bookmark the permalink.
  • Chris

    Very useful. I installed the desktop as you described. One problem arises when using the package manager or other administrative tasks in the desktop. A password is required, however which password is that ? none of the passwords work. Do you have the same issue ?

  • dennis

    On the command sudo sed -i ‘s/maverick/lucid/g’ /etc/apt/sources.list.d/freenx-team-ppa-maverick.list 

    I get a “No such file or directory”.  I check the directory and the freenx-team-ppa-maverick.list  the file is there. I am doing the command from the root.
    Is there something I am missing.

  • Anonymous

    In step 3 you needed to set up a password. It is the same password used lo log in.

  • Chris

    It didn’t work for me either, so I edited by hand. It seems to me that (1) -e is the required sed option, not -i (2) The `s/maverick/lucid/g’ should not start with a backquote. Try this:
    sudo sed -e ‘s/maverick/lucid/g’ /etc/apt/sources.list.d/freenx-team-ppa-maverick.list

  • Anonymous

    Are you using Ubuntu 10.10?

  • Chris

    Yes, the password works for log in, but does not work for administrative tasks inside the desktop.

  • Anonymous

    Did you try in the terminal? This would usually be more informative as to what the problem is.

  • David B

    I am having the same issue on 11.04 – any time you would be prompted for a password to make a change, nothing shows on screen. An example would be adding a user from the GUI (Click System / Admin / Users and Groups

  • Anonymous

    I used 10.10 for this example. I guess something is missing for this to work on 11.04.