Remote desktop on AWS EC2

Server

Install RDP server on EC2:

sudo apt update
sudo apt install -y ubuntu-desktop xrdp

Configurations present at: /etc/xrdp/xrdp.ini

Install XFCE:

sudo apt install -y xfce4 xfce4-goodies
echo xfce4-session >~/.xsession

(Probably optional) Set a password for the ubuntu user: sudo passwd ubuntu.

Restart XDRP: sudo service xrdp status

Client

Setup SSH port forwarding from laptop to EC2.

Using AutoSSH:

autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3"  -i ~/.ssh/ec2-keypair-1 -NfL localhost:8889:localhost:3389 ubuntu@ec2-34-216-247-145.us-west-2.compute.amazonaws.com

Or the usual way:

ssh -i ~/.ssh/ec2-keypair-1 -NfL localhost:8889:localhost:3389 ubuntu@ec2-34-216-247-145.us-west-2.compute.amazonaws.com

Connect to localhost:8889 from laptop’s Microsoft RDP client.