How to Create an AWS Instance with Ubuntu Desktop

Part 1: Setting up your first AWS instance

Amazon Web Service and other cloud services such as Microsoft Azure have become popular lately because they allow companies to purchase computing resources only as they are needed, substantially reducing upfront investment costs and barriers to entry for growth.

AWS is the most popular service and they have some free tiers for computing resources, so today we’ll discuss AWS. Most of these services work by allowing a user to start a virtual machine (like a remote desktop computer) on the server computer at the cloud service company, Amazon in this case.

The cloud company can start, stop and run many of these virtual machines on a single server, saving money compared to a company that would otherwise have to leave one computer on for each person by using the computers and electricity more effectively.

Let’s dive in to the AWS interface for setting up the virtual machine.

First, you’ll need to go to the AWS home page, then setup an account by clicking “Create an AWS Account” in the upper right corner and following the prompts. You will need to include credit card information so they can bill you for using their computing services.

Once you create your account and log in, you will be presented with the AWS management console.

Select “Launch a virtual machine,” then choose an operating system type. In this case we’ll choose Ubuntu because it is more popular, easier to use, and eligible for the free tier.

Next, choose an instance type. We’ll choose t2.micro since it’s eligible for the free tier and will cost less.

Continue through the prompts until you reach the “Review” step. Now you are ready to launch the instance. Just press “Launch.”

You will need to create a security key. Give it a good name and remember where you saved it.

Once the instance is launched, it will be running but you won’t see it.B y clicking on the Instance ID, you can open it. A new tab will open with a terminal window for your new instance! You can type the commands into the window to control your AWS instance.

Part 2: Adding the Desktop Graphical User Interface

2a: Installing the remote capabilities into the instance

This instance acts as a remote computer with only a command line for user interface. It comes with no GUI because many companies would run a minimal instance without an interface that only uses a few custom programs. The instance and the programs would be turned on and called automatically based on user demands. In our case, for the purpose of using the instance as a computer and demonstrating basic AWS knowledge, we will add a user interface so the instance can be treated more like a normal remote computer. The Ubuntu webpage offers clues on how to add the GUI which I will expand upon. 

You can copy and paste the commands below, one line at a time into your terminal. You should click into the terminal and press “CTRL+V” to paste. These commands update the instance, then install the ubuntu desktop program, a remote control server, and some additional supporting programs.

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

Below shows an example of what the terminal in the webpage looks like after you enter the first command.

Next, you will start the VNC server and then open the configuration file for the vnc server using the built-in vim text editor with the following two lines:.

 vncserver :1
 vim ~/.vnc/xstartup

Once the configuration file is up, press “i” to type the below lines into the file and delete the existing lines. Copy the following lines into the terminal so it matches exactly.

[ -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 &

Once you’re done, press “esc” then “:wq” then “Enter” to stop editing, save and quit vim. Then, restart the vnc server using the following commands:

vncserver -kill :1
vncserver :1

Note that in this configuration, every time you reboot the AWS instance you will need to open the terminal and type the line below to start the vncserver before you can remotely login.

vncserver :1

2b) Configuring AWS network security settings to allow remote desktop

Now you will need to open up ports for communication between your computer and the AWS remote desktop instance. Go back to the AWS webpage for the instance summary and click on the “Security” tab in the middle of the page, then click the link below “Security Groups” indicating the security group.

Selecting the security group will take you to a new page. You click “Edit Inbound rules,” then add the HTTP and Custom TCP ports so the rule matches like below.

Now your AWS instance is ready to remotely log in. Working from an Ubuntu computer with LTS 16.04 or newer, you can open the “Remmina” software for handling the remote login. You can copy the login address from the “Public IPV4 DNS” on your instance description webpage, then paste it into remmina followed by “:1” for the remote viewer port number. It should look something like below. Also select the VNC setting in Remmina. If you’ve done everything correctly, this should prompt you for a password to log in to your desktop!

Now the desktop looks good and the browser is already installed, so this instance is ready to work with! Just make sure to “Stop Instance” from the “Actions” tab of the AWS Instance Webpage when you’re done to avoid getting charged for unused time.

Leave a Reply