Published February 25, 2023 by

How to launch Linux OS from EC2-instance as GUI ?

 

In this article, I will set up a GUI environment from AWS EC2 services AMI Linux Images which is Deafut as CLI.

Let's go through each step to find the way to launch in GUI mode.

  1. AWS Account
  2. MATE desktop environment
  3. Any VNC Services (TigerVNC)
  4. Tiger VNC Client Software On your Host Windows OS
  5. For a Better hands-on, Use Putty as a Remote login via SSH to access the Linux

Here, I have Guided you with the Steps to be followed,

Launch an instance with the Configuration of AWS

If you have already launched an Instance and want to proceed with manual GUI installation, then do the following:

  1. Install the MATE desktop environment, a lightweight GUI based on GNOME 2 available as an extra for Amazon Linux 2
  2. Install the MATE desktop environment manually.
  3. Install a VNC service like TigerVNC. To download Check Out the tigervnc.org website.
  4. Connect to the GUI using the VNC.

Here we use the Pre-Setup configured MATE desktop environment.

  1. Open putty, Enter your instance Public IP in the Hostname and connection type SSH type.
  2. Now go to Connection > SSH > Auth > Credentials.
    Upload your ppk file, which we have downloaded from Amazon in Step-3.
  3. Select Open.
#grep PRETTY_NAME /etc/os-release
sudo yum updates

This is to Update the Sofware programs as a whole.

The Packages are updated.

sudo amazon-linux-extras install mate-desktop1.x
sudo bash -c ‘echo PREFERRED=/usr/bin/mate-session > /etc/sysconfig/desktop’
sudo yum install tigervnc-server

Configure a VNC-specific password, then limit VNC network access to the local host, so that VNC can only be accessed via a secure SSH tunnel.

Then, create a mandatory configuration file that includes the localhost option.

Create the tigerVNC configuration directory

vncpasswd
sudo mkdir /etc/tigervnc
sudo bash -c 'echo localhost > /etc/tigervnc/vncserver-config-mandatory'
sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@.service

Replace all occurrences of USER in the new unit with ec2-user using the sed command. Reload the systemd manager configuration after that.

Start the service.

sudo sed -i 's/<USER>/ec2-user/' /etc/systemd/system/vncserver@.service
sudo systemctl daemon-reload
sudo systemctl enable vncserver@:1
  • Enter your Instance public IP in the Hostname and “connection type” SSH type.
  • Now go to Connection > SSH > Tunnel
  • In Source port, Add 5091 and Destination- “ localhost:5091” then click on add.

Click on Open.
Now Start the service with the following command —

sudo systemctl start vncserver@:1 
sudo systemctl status vncserver@:1
sudo systemctl enable vncserver@:1

Now, When Going to the tigerVNC client which,asks for the VNC server hostname, enter “localhost:1” and then click on connect button.

Enter the VNC password that you set up previously.

Here is your GUI running on the Amazon Linux2 image.

Thank you !!