Remote Desktop on an Ubuntu EC2 Instance

Cloud

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 update
sudo apt install -y ubuntu-desktop xrdp
  1. Edit the RDP configuration file, /etc/xrdp/xrdp.ini, on the host. A minimal configuration might look like this:
[globals]
bitmap_cache=yes
bitmap_compression=yes
port=3389
crypt_level=low
channel_code=1
max_bpp=24

[xrdp1]
name=sesman-Xvnc
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=ask-1

Note the entry for port, which will be important for making a connection.

  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 install -y xfce4 xfce4-goodies
echo xfce4-session >~/.xsession
echo unity >~/.xsession
  1. Connect.
  • On a Linux machine, connect using vinagre. You’ll need to specify the IP address for the EC2 host and the RDP port.

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

Once you’re authenticated you should see your desktop.

  • On a Windows machine use the Remote Desktop client.

Categorically Variable