i tried configuring ec2 ubuntu-desktop from MacOS

2021.10.15

Overview

the setup of running ubuntu desktop on an AWS EC2 instance using TightVNC on a system running Ubuntu 16.04+.

What you’ll need :

  • Access to an AWS EC2 instance using commandline
  • A machine running ubuntu 16.04+
  • Royal TSX 2

Steps :

Create ec2 instance

We need to make sure that the AWS instance has inbound rules setup to allow connection using VNC. So, head over to your AWS EC2 console and modify the inbound-rules. Add the entry : Custom TCP Rule | TCP | 5901 | Custom | 0.0.0.0/0 | VNC Connect

Setting up TightVNC on AWS

Let’s install Ubuntu Desktop and TightVNC on your EC2 instance. After logging in to your EC2 instance using the terminal, enter the following commands to install the tools that will be required to run Ubuntu desktop :

sudo apt update
sudo apt install ubuntu-desktop
sudo apt install tightvncserver
sudo apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

While installing VNC Server you’ll be required to setup a password for the server. So remember this since it will be needed later to connect to our VNC server.

Configuring the VNC server

In your terminal type the following command to launch VNC server to create an initial configuration file:

vncserver :1
  1. Open the configuration file in vim:
vim ~/.vnc/xstartup

and replace  the code with the bellow code

 

#!/bin/sh

export XKL_XMODMAP_DISABLE=1

unset SESSION_MANAGER

unset DBUS_SESSION_BUS_ADDRESS

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &

Great! We’re almost done with the configuration. Now, let’s restart the VNC server by killing it first and then starting it up.

To kill the vnc server and start it again, type the following command:

Connecting to Ubuntu Desktop

  1. install royal tsx 2 from this link Click here
  2. move installed file to application folder
  3. open royal TSX 2
  4. for installing plugins open the "Royal TSX" menu and select the "Preferences" menu item, then navigate to "Plugins". and install VNC
  5. go to file and create new document
  6. connection>add>vnc add a Display name computer name :" ec2 public ip address" port: 5901
  7. navigate to credentials: 1. select Specify username and password:

    1. username- ec2-user
    2. password : "give a password you created in ec2 server"
  8. apply changes
  9. click on display name and virtual desktop is visible

Reference