How do I install a GUI on my Amazon EC2 instance running Amazon Linux 2?

How do I install a GUI on my Amazon EC2 instance running Amazon Linux 2?

AWS   /   Mar 15th, 2023   /   0 COMMENTS   /  A+ | a-
Before you proceed, first consider one of these alternatives to manually installing a GUI:
  • Launch from an Amazon Linux 2 AMI that comes with MATE pre-installed
  • Start using Amazon WorkSpaces, a fully managed, persistent desktop virtualization service.
  • Start using NICE DCV, a remote display protocol that delivers remote desktops and application streaming securely from any cloud or data center to any device.
If you 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. For more information about MATE
  2. Install a virtual network computing (VNC) service, such as TigerVNC. For more information about TigerVNC, see the tigervnc.org website.
  3. Connect to the GUI using the VNC
  4. (Optional) Turn off password authentication for VNC.
  5. (Optional) Install a web browser, such as Chromium or Firefox.
Connect your instance as EC2-user using SSH
  • The instance must be in a Public Subnet and accessible through a public IP address or an Elastic IP address
  • Update your instance by running sudo yum update, and then reboot  the instance
  Install MATE packages.
  • Install MATE packages.
sudo amazon-linux-extras install mate-desktop1.x
  •  Define MATE as your default desktop for all users.
sudo bash -c 'echo PREFERRED=/usr/bin/mate-session > /etc/sysconfig/desktop'
  • Install TigerVNC Server:
sudo yum install tigervnc-server
  • Configure a VNC-specific password containing from six to eight characters for this user. When asked if you want to enter a view-only password, press "n".
vncpasswd
  • Restrict VNC network access to the localhost, so that VNC can be accessed only by using a secure SSH tunnel.Create the tigervnc configuration directory:

sudo mkdir /etc/tigervnc
  • Create a mandatory configuration file containing the localhost option:
sudo bash -c 'echo localhost > /etc/tigervnc/vncserver-config-mandatory'
  •  Start the VNC Server on display number 1, and cause it to always start at boot time. Create a new systemd unit.
sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@.service
  • Use the sed command to replace all occurrences of USER in the new unit with ec2-user.
sudo sed -i 's//ec2-user/' /etc/systemd/system/vncserver@.service
  • Reload the systemd manager configuration.
sudo systemctl daemon-reload
  • Turn on the service.
sudo systemctl enable vncserver@:1
  • Start the service.
sudo systemctl start vncserver@:1
 

Connect to the GUI using VNC

 Install the TigerVNC software on your local computer, if it's not already installed. TigerVNC is available for Windows, Linux, and macOS. See the TigerVNC website to access the download.
 

Windows

When opening the connection with PuTTY, configure port forwarding, and then open the connection:

  1. From the Connection menu, select SSH, and then select Tunnels.
  2. Enter 5901 in the Source Port field.
  3. Enter localhost:5901 in the Destination field.
  4. Select Add.
  • Open the TigerVNC Viewer on your local computer. When asked for the VNC server hostname, enter localhost:1 and then connect to it.
  • Enter the VNC password that you set up in step 2 of the Install TigerVNC section. If an alert appears stating that the connection isn't secure, disregard it. You're accessing the VNC server using an encrypted SSH tunnel.
  • Your MATE desktop environment appears.

Mentor - Amol Gaikwad
Intormation and research are sources from internet.
 
No comments posted...

Leave a Comment

Simple catpcha image
Top