Friday, November 12, 2010

Show Off Ubuntu Desktop on Cloud

Want to show off your Ubuntu desktop in the cloud ? Perhaps you want to demo it to some Windows or OSX friends. Perhaps new users at your loco event want to play with Ubuntu for a bit. Well, look no further. In this article I will create an Ubuntu maverick 10.10 desktop in the Amazon ec2 cloud, connect to it using the x2go terminal server, which leverages the excellent NX remote display libraries

Start by launching the following AMI (ami-1a837773). I chose the official Ubuntu 32bit ami, so that we can run it on a m1.small instance. If you're not sure how to launch this instance, you might want to review my point-n-click guide. After launching the instance and logging in, I do my customary

ssh ubuntu@xxxxx   #replace with your instance's public dns name
sudo -i
apt-get update && apt-get dist-upgrade -y

Let's install x2go terminal server
# gpg --keyserver --recv-keys C509840B96F89133
# gpg -a --export C509840B96F89133 | apt-key add -
# echo "deb lenny main" >> /etc/apt/sources.list
# apt-get update
# apt-get install x2goserver-home

Optional step: Switch system to libjpeg-turbo

I like to break my Ubuntu system by installing unsupported software, so I will be switching the system's default libjpeg into a newer variant that utilizes your CPU's SIMD instruction set to provide better performance. Since connecting to a desktop remotely, heavily utilizes jpeg compression I suspected this step would provide me a performance boost. It is however not recommended, especially to someone who wouldn't be comfortable fixing his system using console only. You need to do the following on the ec2 server and on your own system. I am assuming 32bit systems, you can 32/64 bit versions here
# wget '' -O libjpeg-turbo_1.0.1_i386.deb
# dpkg -i libjpeg-turbo_1.0.1_i386.deb
Selecting previously deselected package libjpeg-turbo.
(Reading database ... 25967 files and directories currently installed.)
Unpacking libjpeg-turbo (from libjpeg-turbo_1.0.1_i386.deb) ...
Setting up libjpeg-turbo (1.0.1-20100909) ...

# ls -l /usr/lib/
lrwxrwxrwx 1 root root 17 2010-11-12 12:35 /usr/lib/ ->
# rm -rf /usr/lib/
# ln -s /opt/libjpeg-turbo/lib/ /usr/lib/

Install the Ubuntu desktop itself (The GUI)
apt-get install ubuntu-desktop
This takes a good 10-15 minutes. After which your system is ready. Grab yourself a favourite x2go client here. Send your friends links to the Windows and OSX clients and let them see the light :) In my case I just used my Ubuntu system to connect remotely. So I added the same repo we added before and installed "x2goclient" which is a qt4 client. Here are the settings I used


I am using my ssh key to login to the Ubuntu virtual desktop. If you're using Win/OSX and perhaps wouldn't want to use the ssh key, reset the Ubuntu user password and connect using the password. Once connected we see our familiar and beautiful Ubuntu desktop


I was pleasantly surprised to hear the drums-beating sound of Ubuntu booting! wow! That was just awesome. x2go uses pulseaudio to remotely connect and bring audio right to your desktop. I also could easily forward my local files to the instance in the cloud. Anyone already using Ubuntu desktop in a cloud ? let me know about it ? What kind of use cases you'd use such a setup for ? If you have some fancy setup, let me know about it as well


Anonymous said...

x2go looks great, but what's the future of x2go regarding the move to wayland?

bmullan said...

I'm sure x2go will adapt to wayland like everyone else will.

Keep in mind from what I have read, even when Wayland arrives you still have X available to you

Ahmed Kamal said...

It's way too early for Wayland, while it is the future, I don't expect it to replace X for a couple of years. When that does happen, I do hope Wayland can offer superb remote display capabilities, I know that is being designed at the moment

Anonymous said...

I did a similar thing behind the firewall at home. I use Ubuntu 10.x and nomachine to secure surf the web from unsecured hotspots like Starbucks:

Great solution, gives me access to printers my lab and cameras at home- and best of all, all history stays at home

q said...

for some reason i cannot execute the first command:
ssh ubuntu@xxxxx #replace with your instance's public dns name

any suggestions ?

Ahmed Kamal said...

Hey q,
You should replace "xxxx" with the DNS name or IP address of your virtual server at ec2. So, in reality this command would look similar to


except that the 4 numbers after @ec2 would be different. You can get the correct numbers by clicking your instance in the aws console and reading the "Public DNS" name

Check out this pic if unsure

q said...

i tried to modified password
of user 'ubuntu' with the following command:
sudo passwd ubuntu

but, i was unable to connect.
i get "Connection failed... Permission denied (publickey)".

does someone know how do i solve this problem ?

Ahmed Kamal said...

Not tested, but can you edit the file "/etc/ssh/sshd_config" and change

PasswordAuthentication no
PasswordAuthentication yes

then restart sshd like

sudo /etc/init.d/ssh reload

q said...

changing the 'PasswordAuthentication' made the trick.

another problem:
i am unable to start firefox.
any ideas here ?

Ahmed Kamal said...

Hey q, what error are you getting ? Try starting it from a terminal

q said...

sorry, my mistake.
firefox has started after a while.

it seems that a small vm in ec2 is a little slow for using ubuntu with desktop.

q said...

BTW, i am unable to share a directory from windows(with x2go windows client) to use (and pass files) to the ubuntu remote machine.
any suggestions here ?

Ahmed Kamal said...

Glad that it works for you! Not sure about sharing files from windows though. Try joining the x2go community, they are going to have more experience with x2go than myself :) Enjoy

Anonymous said...

Pretty much like Greg I have a machine somewhere and am running NX there and connect to it to check mail, have my history & passwords saved there...
Hosting this at Amazon sounds interesting but I would be interested in how Setup works (never used AmazonWS) and what I costs...

Best Regards, and good writeup for people new to X-Forwarding/Remote-Desktop..., but I am more the "new to AmazonWS"-Guy...

Ahmed Kamal said...

Hey Nailor,
Glad you liked the write up. You can get a tiny server at ec2 for free for a year! (yes what you read is true). Check this out

Since you mention you're new to ec2 in general, this visual guide might be helpful

Marc said...

This is, almost, exactly, what I was looking for.

What if, instead of installing a client software, say you're in a corporate environment, or access it through a public computer? Isn't there a way to put Ubuntu in the Cloud and have it accessible similar to something like the JolliCloudOS from within a browser instead?

Or, is there a portable Apps version of X2Go that I could keep on a flash drive and use, so it's more secure?

Ahmed Kamal said...

Hey Marc,

For the portable app try

It's my understanding an x2go java browser plugin is under development, such that no software installation is needed indeed

Marc said...

At the following step:

# gpg --keyserver --recv-keys C509840B96F89133

I get the following:

gpg: keyserver timed out
gpg: keyserver receive failed: keyserver error

I went into the AWS Management Console and opened the following ports based on some forum posts I found:

UDP 30350-30351
UDP 9103

Was there any other ports I needed to open in the AWS MC??

Ahmed Kamal said...

Hey Marc,

For the gpg error, you can try another server like

gpg --keyserver --recv-keys C509840B96F89133

For opening ports, I believe you only need to open port 22 for ssh. X2go is tunneled over ssh AFAICT

Marc said...

Thanks Ahmed. That string to grab the keypair worked.

Marc said...

This has been a great guide, and I thank you for your help in getting this up and running.

The next issue I encountered is using the .perm key to work on my windows X2go session.

do I need to generate my own id_rsa key on Ubuntu or Putty and use that instead?

Ahmed Kamal said...

It's probably easiest for you to use password authentication instead of keys. Scroll up to read my comment on "PasswordAuthentication"

Marc said...

No luck, unfortunately.

$ cat /etc/ssh/sshd_config | grep Password
PermitEmptyPasswords yes
PasswordAuthentication yes

When X2go failed, tried cmd line from a 'nix box I have access to, and it also failed:

> ssh ubuntu@ec2-
Enter passphrase for key '/home/<>/.ssh/id_rsa':
ubuntu@ec2-<>'s password:
Permission denied, please try again.

**As you can see, I know just barely enough to be dangerous with my own box.

Ahmed Kamal said...

Did you restart "ssh" service after changing the config ? Did you reset the ubuntu user password using "passwd ubuntu" ?

If so, then I'm not sure what went wrong. Perhaps this page is helpful for using key authentication with putty from windows

M. Walsh McGuire said...

Thanx very much for these posts and your helpful comments.
1 last question - in X2Go the n/p you use is ubuntu/RSA key pair file?
I am not sure what to use.

Many thanx!

Ahmed Kamal said...

Yes indeed, username=ubuntu and instead of the password I used the private key (note that the public key was readily injected inside the VM by Amazon) so I could login

If you're on Windows ? read my previous comments about changing "PasswordAuthentication" to yes, restarting ssh service, changing the ubuntu user's password using "sudo passwd ubuntu" and thus being able to ssh into the machine using a username/password

Another option may be to create a new user and add it to the x2gousers group by

sudo adduser username x2gousers
sudo passwd username

Good luck, if things work out for you, I'd be glad if you could send me a write up of exactly the steps that were needed

Ezrie said...

Worked like a charm on my home pc (win7). ON my work pc (also win7) x2go says it can't connect to xserver. In Options > settings there is a "general" tab that is not present on my home computer. This tab seems to be asking for an X configuration. Any ideas?

Ahmed Kamal said...

Hey Ezrie,

hmm, not quite sure why you're hitting that. Things I'd try:

- Maybe "work" is blocking outgoing ssh access to the server? can u use putty to ssh into it?
- If not, I suspect the difference is that on "home" PC, you're an administrator account. While on "work" PC you're not. Can you actually run x2go client, by right clicking and choosing run as administrator ?

Other than that, your best bet is probably asking on the x2go forums or mailing list. Have fun

Paolo said...

Hi Ahmed, I read the two guides "Show Off Ubuntu" and "Point-n-Click" and I think they are wonderful. I was able to create an EC2 t1.micro Ubuntu instance and access it with X2Go client from my Windows Vista PC. I changes the "Password Authentication" as you suggested. However when I login I get this error message from X2Go client: "Can't read host rsa Key:C:\Program Files\x2goclient\etc\". I'm not sure if this error message is important and if I should try to fix this issue. Any idea? Thanks again for sharing this info. Cheers, Paolo (Italy)

Ahmed Kamal said...

Hi Paolo,

Glad you found it useful. I do not think this message is important. My understanding is basically, ssh generates a host key on each machine, x2go it seems has not done that, thus the warning. You can ignore it, or you can generate and put any keypair there I suppose

stisi said...

Thanks for your great tutorial!

I run a ubuntu desktop on a free tier micro instance.

Thats cool!!

Would be NX better then x2go?

Thanks, Wolfgang

marco said...

Well done, thanks you!

marco said...

Well done, thanks you!

Edouard Villeneuve said...


We are currently trying to move from NX to X2Go (on RHEL).

While we have what I would consider typical needs and usage, we are caing numerous issues: color issues with a minority of our GUI tools impacting their usability, client crashes with some other tools, etc.

I am struggling to find expertise to move forward - either forum, technical support or even consulting to ensure our implementation is better controlled.

Any suggestions there?