How To Setup GUI For Amazon EC2 Ubuntu Linux Instance

After I set up an Amazon EC2 Ubuntu Linux server, I can only access it with ssh command. But I really need the GUI interface to browse the ubuntu server easily. After investigating, I finally find the below method of how to enable the XServer on the amazon EC2 Ubuntu Linux server and how to connect to it with Microsoft remote desktop.

1. Enable GUI Access In Ubuntu Linux Server Side.

My ubuntu server version is 18.04.

  1. Connect to the Amazon EC2 Ubuntu Linux server with the ssh command line.
    ssh -i "/Users/.../key.pem" ubuntu@ec2-18-86-1-18.compute-1.amazonaws.com
  2. Update ubuntu server.
    sudo apt-get update -y
  3. Install lxde package. This process may take some time to install a lot of packages.
    sudo apt-get install lxde -y
  4. Install xrdp to allow the remote desktop connection.
    sudo apt-get install xrdp -y
  5. Set a password for user ubuntu, this username is the default username when you use Microsoft remote desktop to connect to the ubuntu server.
    sudo passwd ubuntu

2. Change Amazon EC2 Instance Security Group To Allow Remote Desktop Inbound Connection.

  1. Go to the Amazon EC2 Dashboard console in a web browser.
  2. Click the INSTANCES —> Instances menu item on left. In the right instance list panel, click the link in the ubuntu server instance Security Groups column.
  3. Then it will open the security group detail page. Click the Inbound tab.
  4. Click the Edit button below the Inbound tab to open the Inbound rule edit dialog.
  5. In the pop-up dialog, click Add Rule button then select RDP type, the port range number will be set to 3389 automatically.
  6. Input the source IP (0.0.0.0/0 if you want to access this ubuntu server instance from any IP address), click the Save button to save the changes.

3. Change Ubuntu Firewall Rule To Allow Access Port 3389.

  1. Besides adding the allow port number 3389 rule in the amazon security group, you also need to allow to access 3389 port in Ubuntu.
  2. Run the command sudo ufw status to list all the current firewall rules.
  3. Run the command sudo ufw allow 3389/tcp to add the rule to allow access to port number 3389.
  4. Run the command sudo ufw status again to check whether the port number 3389 has been added or not.

4. Connect To EC2 Ubuntu Server Use Microsoft Remote Desktop.

  1. Open Microsoft remote desktop and add a server.
  2. Input the amazon EC2 Ubuntu Linux server IP address, then click Add button to add it.
  3. Double click the newly added server to connect to it, input username ubuntu and the password that you configured in section 1 in the popup authorization dialog. Then you can use the ubuntu server with GUI.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.