Tutorial: Connecting to AWS EC2 Ubuntu Desktop

I spent a Saturday morning trying to connect to an AWS EC2 desktop after trying to follow the instructions given by AWS on Connecting to Ubuntu Desktop with Windows that completely failed.

The instructions described here are derived from the following YouTube Video. There were some parts that were not clear/correct so I have clarified and corrected them in this post.

Configure Ubuntu Desktop Server

sudo -s
  • Update the operating system
sudo apt update && sudo apt upgrade
  • Type the following commands to install vncserver:
sudo apt-get install ubuntu-desktop
sudo apt-get install vnc4server
sudo apt-get install gnome-panel
  • Start the VNCServer.
  • Remember the password you set. You will need this passcode later when you connect using tightvnc .
  • Kill vncserver
vncserver -kill :1
  • Modify the VNC startup script
vi .vnc/xstartup
  • Add the following lines to the .vnc/xstartup script
# Uncomment the following two lines for normal desktop:
# exec /etc/X11/xinit/xinitrc
gnome-session –session=gnome-classic &

xstartup script

  • Press ESC, followed by :wq (write-quit) to save and exit the file
  • Start the VNCServer again

Configure your Windows Box

Configure your EC2 Instance

  • Edit your security group.
    Edit your Security Group
  • Add port number 5901 in your ec2 security group
    Add Port 5901 to security group
  • Write your public ip number (or DNS name) in remote host text box and port number <publicIp>::5901
  • Your desktop in ec2 instance is ready and execute the command vncserver after every restart.


  • Can I stop my machine and restart it?: Yes. However you will have to re-run the vncserver command after restarting the server.

1 thought on “Tutorial: Connecting to AWS EC2 Ubuntu Desktop”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.