Remote Desktop to EC2-Ubuntu

Remote Desktop to EC2-Ubuntu

Some users prefer the Desktop interface of the Windows operating system, and transitioning to the Terminal interface of the Linux operating system can be a bit challenging. This guide will walk you through installing a desktop interface on Ubuntu, which is a Debian GNU/Linux-based computer operating system. This will allow you to seamlessly switch between these two interfaces.

Note:

  • Before proceeding, ensure you’ve completed Step 4.1: Create Linux instance to set up your EC2 instance.
  • In the AMI selection step, use the following information:
    • Name: Ubuntu-instance
    • Choose Quick Start
    • Select Ubuntu
    • AMI: Ubuntu Server 22.04 LTS

Create VPC for Linux Instance

  1. Check EC2-Ubuntu Status in the EC2 Console
  • Verify that Ubuntu-instance is selected
  • Ensure that the EC2 instance is in a Running state

Create VPC for Linux Instance

  1. Connect to the EC2 Instance
  • Choose Ubuntu-instance
  • Click Connect

Create VPC for Linux Instance

  • Select EC2 Instance Connect
  • Click Connect

Create VPC for Linux Instance

  • In about 10 seconds, you will be redirected to the Terminal screen of Ubuntu-instance

Create VPC for Linux Instance

  1. Install the Desktop Interface Environment on Ubuntu-instance
  • Run the command: sudo apt update to update the list of available packages
  • Result:

Create VPC for Linux Instance

  • Run the command: sudo apt install xfce4 xfce4-goodies -y to install Xfce and Xfce goodies
  • Xfce is a lightweight and user-friendly desktop environment for Ubuntu virtual machines, running on Linux.
  • Note: This may take 5-10 minutes to download and install the packages, depending on your network bandwidth and EC2 instance type. Learn more: link
  • Result:

Create VPC for Linux Instance

  • Note: If prompted to choose a graphical login mechanism and user session, select gdm3 for this lab. Otherwise, ignore this note.
  1. Install xRDP on Ubuntu-instance
  • xrdp is an open-source software that enables RDP connections for servers running Linux operating systems.

  • Run the command: sudo apt install xrdp -y to install xrdp

  • Result:

Create VPC for Linux Instance

  • Run the command: sudo systemctl status xrdp to verify the status of xrdp
  • Result:

Create VPC for Linux Instance

Note:

If xrdp is not running, use the following commands to start the service:

  • Run the command: sudo systemctl start xrdp, then
  • Run the command: sudo systemctl status xrdp to verify the status of xrdp
  1. Review the default configuration of xrdp
  • Run the command: sudo nano /etc/xrdp/xrdp.ini
  • Result:

Create VPC for Linux Instance

Note:

By default, the user and password parameters are set to ask, meaning the user will need to enter their user and password to connect via RDP.

Create VPC for Linux Instance

To exit the nano editor and return to the Terminal interface, press: Ctrl + X

  1. Create a .xsession File

The .xsession file adds xfce4-session as the session manager for login.

  • Run the command: echo "xfce4-session" | tee .xsession
  • Result:

Create VPC for Linux Instance

Note:

This configuration ensures that xfce4-session is used as the session manager for the graphic login - Desktop interface. Since xfce is the chosen environment for the Desktop interface, xfce4-session functions as the session manager. Failing to include this in the .xsession file will prevent RDP sessions from connecting to the graphical login - Desktop interface.

  • Run the command: sudo systemctl restart xrdp to restart xrdp, then
  • Run the command: sudo systemctl status xrdp to verify the status of xrdp
  • Result:

Create VPC for Linux Instance

  1. Create a Password to Login to EC2-Ubuntu Using RDP
  • Run the command: sudo passwd
  • Enter a password (e.g., vdp123)
  • Re-enter the password: vdp123
  • Result:

Create VPC for Linux Instance

Note:

Remember to save the password you’ve just created; you’ll need it for step 9.

  1. Configure Inbound Rule for RDP Protocol on EC2 Ubuntu-instance
  • In the EC2 console, select your EC2 Ubuntu-instance
  • Choose Security

Create VPC for Linux Instance

  • Select Security Groups, e.g., sg-0a404955f5124b1cd (launch-wizard-22)

Create VPC for Linux Instance

  • You’ll be redirected to the Security Groups console; choose Edit inbound rules

Create VPC for Linux Instance

  • Click Add rule in the top left corner

Create VPC for Linux Instance

  • Under Type, click the dropdown arrow to reveal the protocols

Create VPC for Linux Instance

  • Type RDP in the input box and select RDP

Create VPC for Linux Instance

  • In the Source section, click the dropdown arrow to display the options:

    • Choose MyIP: This allows only your local IP address to access EC2 Ubuntu-instance using the RDP protocol. For enhanced security, it’s recommended to select MyIP.
    • Choose Anywhere-IPv4: This allows all IPv4 addresses to access EC2 Ubuntu-instance using the RDP protocol.
  • For this lab, choose MyIP

  • Click Save rules

Create VPC for Linux Instance

  1. Log into EC2 Ubuntu-instance Using RDP Protocol

In the EC2 console, copy the Public IP address of your EC2 Ubuntu-instance, which you’ll use in the following step

Create VPC for Linux Instance

On your local Windows desktop:

  • Click the search icon in the bottom left corner of the screen
  • Type: RDP in the search box
  • Choose Remote Desktop Connection

Create VPC for Linux Instance

The Remote Desktop Connection window appears

  • In the Computer field, paste the Public IP address of your EC2 Ubuntu-instance
  • Click Connect

Create VPC for Linux Instance

The 54.169.159.102 - Remote Desktop Connection window appears

  • Session: Xorg
  • Username: root
  • Password: vdp123 (created in step 7)
  • Click OK

Create VPC for Linux Instance

Congratulations! You’ve successfully connected to EC2 Ubuntu-instance using the RDP protocol. From here, you can easily switch between the Desktop interface and the Terminal.

Create VPC for Linux Instance

  1. Let’s Try Some Commands in the Terminal!
  • In the bottom corner of the screen, click the Terminal icon

Create VPC for Linux Instance

  • Run the command: lsb_release -a to check the Ubuntu version
  • Run the command: dig +short myip.opendns.com @resolver1.opendns.com to check the Public IP

Create VPC for Linux Instance