Remote Desktop on an Ubuntu EC2 Instance (2024)

A couple of options for remote access to desktop applications on a EC2 host.

Option 1: SSH with X11 Forwarding

  1. Connect to the EC2 host using SSH with X11 forwarding enabled.
ssh -X 13.57.185.127
  1. In the resulting session you should find that the DISPLAY environment variable is set.
echo $DISPLAY

With this in place you can launch an application on the remote host and it will show up on your local desktop. Try starting gvim (assuming that you have it installed).

Option 2: Remote Desktop

  1. Connect via SSH.
  2. Install a few packages.
sudo apt updatesudo apt install -y ubuntu-desktop xrdp
  1. Edit the RDP configuration file, /etc/xrdp/xrdp.ini, on the host. Note the entry for port, which will be important for making a connection. A minimal configuration might look like this:
[globals]bitmap_cache=yesbitmap_compression=yesport=3389crypt_level=lowchannel_code=1max_bpp=24[xrdp1]name=sesman-Xvnclib=libvnc.sousername=askpassword=askip=127.0.0.1port=ask-1

💡 Setting crypt_level to none will help to make the remote session more responsive.

  1. In the AWS Dashboard edit the Security Group for the EC2 instance and allow inbound TCP connections on port 3389.
  2. Restart RDP.
sudo service xrdp restart
  1. Choose the Window Manager for RDP connections. This involves changing the contents of a user’s .xsession file. You can copy the modified .xsession into /etc/skel/ so that it will be propagated into any newly created accounts. However, you’ll need to copy it manually into existing accounts.

Select one of the Window Manager options below (there are certainly other options too!).

sudo apt-get install -y xfce4 xfce4-goodiesecho xfce4-session >~/.xsession
  • Unity
echo unity >~/.xsession

You’re ready to connect!

Connecting via RDP

  • On a Linux machine, connect using vinagre. You’ll need to specify the IP address for the EC2 host and the RDP port.

<img src=“vinagre-login.png alt=“The vinagre login dialog.">

A connection will be initiated and you’ll be prompted to provide your password. Leave the port unchanged.

<img src=“remote-desktop-login.png alt=“The xrdp login dialog.">

Once you’re authenticated you should see your desktop.

<img src=“remote-desktop.png alt=“The remote desktop.">

  • On a Windows machine use the Remote Desktop client.
Remote Desktop on an Ubuntu EC2 Instance (2024)

FAQs

Can you rdp into EC2? ›

How to connect EC2 using RDP. Go to EC2>Instances>Launch an Instance. Type 'Windows' as an instance name, and then select Windows as an Amazon Machine Image (AMI).

How to enable RDP on AWS Ubuntu? ›

To allow RDP access

Open the Amazon EC2 console , set it to the stack's region, and choose Security Groups from the navigation pane. Choose AWS-OpsWorks-RDP-Server, choose the Inbound tab, and choose Edit. Choose Add Rule and specify the following settings: Type – RDP.

Why am I unable to connect to my EC2 instance? ›

The following are common reasons why EC2 Instance Connect might not work as expected: EC2 Instance Connect doesn't support the OS distribution. The EC2 Instance Connect package isn't installed on the instance. There are missing or incorrect AWS Identity and Access Management (IAM) policies or permissions.

Why will my remote desktop not connect? ›

One reason for connection problems and other typical errors like 'remote desktop services is currently busy' can be an unstable internet connection. Also, the wrong credentials often cause lead to the remote desktop not being able to connect correctly.

What port does RDP run on? ›

Remote Desktop Protocol (RDP) is a Microsoft proprietary protocol that enables remote connections to other computers, typically over TCP port 3389.

What is the difference between ec2 instance connect and session manager? ›

There many nuanced differences between these services but the basic idea is that EC2 Instance Connect allows for a convenient and secure native SSH connection using short-lived keys while Session Manager permits an SSH connection tunneled over a proxy connection.

What is ec2 instance connect endpoint? ›

Amazon EC2 Instance Connect Endpoint (EIC Endpoint) allows a secure connection to the instances in a private subnet from the internet. It does not require a bastion host, internet gateway in VPC, a public IP address on the resource, or even any agent to connect to the resource.

Does RDS run on EC2? ›

Amazon RDS automatically sets up your related network settings to enable a secure connection between the selected EC2 instance and the RDS database. This connectivity automation improves productivity for new users and application developers.

Can you use RDP to connect to a Linux machine? ›

Anyone with authorized access to a CSL managed Linux computer can connect remotely using an RDP (Remote Desktop Protocol) client.

Do EC2 instances have internet access? ›

An internet gateway enables resources in your public subnets (such as EC2 instances) to connect to the internet if the resource has a public IPv4 address or an IPv6 address.

Top Articles
Latest Posts
Article information

Author: Duane Harber

Last Updated:

Views: 5953

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Duane Harber

Birthday: 1999-10-17

Address: Apt. 404 9899 Magnolia Roads, Port Royceville, ID 78186

Phone: +186911129794335

Job: Human Hospitality Planner

Hobby: Listening to music, Orienteering, Knapping, Dance, Mountain biking, Fishing, Pottery

Introduction: My name is Duane Harber, I am a modern, clever, handsome, fair, agreeable, inexpensive, beautiful person who loves writing and wants to share my knowledge and understanding with you.