How to Access Ubuntu Desktop on AWS EC2

You can install Ubuntu on AWS and access it using SSH on port 22. However, if you want to access the Ubuntu desktop on AWS EC2, then this post will help you with that.

Prerequisite for Accessing Ubuntu Desktop on AWS EC2

  1. Launch an Ubuntu AWS EC2 instance. In case you don’t know how to install Ubuntu on AWS, please follow these steps.
  2. Make sure you have allowed port 5901 in the security group (Described in the link given in step 1).

Steps:

1. After you have installed the server on AWS. Log in to the server. (next steps in case you don’t know how to log into EC2 instance) with default username in Ubuntu and then do sudo su – become root.

2. Software installation is required for Remote Desktop in Ubuntu.

apt-get update
apt-get install ubuntu-desktop
apt-get install gnome-panel
apt-get install vnc4server

3. Now use the vncserver command to enter the password required to access the Ubuntu desktop on AWS EC2.

# vncserver
 
You will require a password to access your desktops.
 
Password:
Verify:
xauth:  file /root/.Xauthority does not exist
 
 
New 'ip-172-31-13-023:1 (root)' desktop is ip-172-31-13-023:1
 
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup

4. Edit the contents of “.vnc / xstartup”:

cat .vnc/xstartup
#!/bin/sh
 
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
gnome-session –session=gnome-classic &
gnome-panel&
# exec /etc/X11/xinit/xinitrc
 
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &

Save and close the file with the command “: wq!” in vi.

5. Now restart the VNCserver process using the commands below.

# vncserver -kill :1
Killing Xvnc4 process ID 8550
 
# vncserver
 
New 'ip-172-31-13-023:1 (root)' desktop is ip-172-31-13-023:1
 
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/ip-172-31-13-023:1.log

6. Now, to access the Ubuntu desktop on AWS EC2, you must download the tiger VNC Java with the viewer enabled from this links

7. Once downloaded, click on the jar file named “TightVNC-jviewer.jar”. and enter the “Public DNS” entry for Ubuntu ec2, for example in the dashboard under the outrigger box that receives the Tiger VNC software.

Enter the above public DNS value in Tiger VNC as shown below:

Ubuntu Desktop Access on AWS EC2

8. Click on the connect button and the system will ask for a password, please use the same password specified in step 3 and click on the “OK” button.

Ubuntu Desktop Access on AWS EC2

9. After successful authentication, you can access the Ubuntu desktop on AWS EC2.

Ubuntu Desktop Access on AWS EC2

So, we are accessing the Ubuntu desktop on AWS EC2.

Sidebar