Setting Up VNC on Ubuntu in Amazon EC2 - Page 3

Setting Up VNC on Ubuntu in Amazon EC2 - Page 3

May 1, 2012

Configuring Ubuntu with the Desktop Environment and VNC Server

Now you can install the desktop packages and remote desktop (VNC) server by entering (or copying and pasting) the following commands one at a time:

sudo apt-get update
sudo apt-get install ubuntu-desktop
sudo apt-get install vnc4server


Now, to configure the VNC server enter vncserver, which will then prompt you to create a password. Once created, enter vncserver -kill :1 to stop the server.

Next, configure the VNC xstartup file so you'll see the desktop when connecting via VNC. Enter vim .vnc/xstartup.

Then hit the Insert key, scroll around the text file with the keyboard arrows, and delete the pound (#) sign from the beginning of the two lines under the line that says "Uncomment the following two lines for normal desktop." And on the second line add "sh" so the line reads exec sh /etc/X11/xinit/xinitrc. When you're done, hit Ctrl + C on the keyboard, type :wq and hit Enter.

Now you can start the VNC server again by entering vncserver. And remember, you must enter this again at every reboot if you want VNC access, or consider configuring it to automatically run at startup.

Connecting to the Ubuntu Instance via VNC

Now that you have Ubuntu set up, you need to install a VNC client (like TightVNC) on your local machine, and when connecting enter the following address:

When connecting via that address you must first connect to the server via SSH (like with PuTTY) and then connect with the VNC client.

If you prefer to connect directly to your Ubuntu instance via VNC rather than having to SSH into it first, you can use the Public DNS address (from the AWS Instances page of your instance) followed by a colon and the number one, such as

Or you could even create an elastic IP and associate it with your Ubuntu instance, which you could then use (also with the colon and 1) to connect via VNC. But remember when connecting directly via VNC, it isn't as secure and you must open port 5901 up on the firewall via the Security Groups page.

Eric Geier is a freelance tech writer. He's also the founder of NoWiresSecurity, which provides a cloud-based Wi-Fi security service for businesses, and On Spot Techs, which provides on-site computer services.

Follow ServerWatch on Twitter