########## VNC INSTALLATION #############

Type the following commands to install vncserver. Also,Type in ‘Y’ when ever prompted.

$ sudo apt-get update

$ sudo apt-get install ubuntu-desktop vnc4server gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

Now, Let’s start the vncserver we have installed and enter a password for vncserver.

You will be asked to create a password which will be used to access your desktop.

$ vncserver

You will require a password to access your desktops.

Password:
Verify:
xauth: file /home/ubuntu/.Xauthority does not exist

New ‘ip-10-0-0-225:1 (ubuntu)’ desktop is ip-10-0-0-225:1

Creating default startup script /home/ubuntu/.vnc/xstartup
Starting applications specified in /home/ubuntu/.vnc/xstartup
Log file is /home/ubuntu/.vnc/ip-10-0-0-225:1.log

If you see the message as shown above, it implies that the vncserver is running. Now, Let’s stop the vncserver to make a few changes to xstartup file:

$ vncserver -kill :1
Killing Xvnc4 process ID 8456

For making changes to the xstartup file, Navigate to the file using the commands below and make changes using vim:

$ cd .vnc

Next, we will comment out the default xstartup script and replace it with the following as shown below:

$ sudo vim xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# 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 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
#x-window-manager &

export XXL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrbd $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &

gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &

After copying the code, save and exit the file. The setup required for the GUI is now complete. Now, It’s time to exit out of ssh instance and connect again for tunneling it to a port.Connect to ssh now using the below command.

$ ssh -L 5901:localhost:5901 -i germany.pem ubuntu@52.59.237.46
The authenticity of host ‘52.59.###.46 (52.59.237.46)’ can’t be established.
ECDSA key fingerprint is SHA2##################2nijp8y0bg/dId##################.
ECDSA key fingerprint is MD##################8:ff:d6:9a:4d##################
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘52.59.###.46’ (ECDSA) to the list of known hosts.
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-1061-aws x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Get cloud support with Ubuntu Advantage Cloud Guest:
https://www.ubuntu.com/business/services/cloud

24 packages can be updated.
13 updates are security updates.

*** System restart required ***
Last login: Fri Jul 20 05:15:10 2018 from 54.239.6.177
ubuntu@imraan:~$

Once you are connected to your instance, Kill the vncserver and then connect back using the resolution settings as below. Please note, you might get an error with running the kill command as shown below however, please move onto setting up the resolution:

ubuntu@imraan$ vncserver -kill :1

Can’t find file /home/ubuntu/.vnc/ip-10-0-0-225:1.pid
You’ll have to kill the Xvnc4 process manually

ubuntu@imraan:~$ vncserver -geometry 1920×1080

New ‘ip-10-0-0-225:1 (ubuntu)’ desktop is ip-10-0-0-225:1

Starting applications specified in /home/ubuntu/.vnc/xstartup
Log file is /home/ubuntu/.vnc/ip-10-0-0-225:1.log

ubuntu@imraan:~$

Once complete, all you will need to do now id download the VNC Viewer:

https://www.realvnc.com/en/connect/download/viewer/

Once downloaded and installed, to connect to the bastian all you will need to do is add the following information:

-VNC server ip or hostname
-Name
-Labels
-Specify security
-Privacy
-Select okay and then connect.

Leave a Reply

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