Skip to content

Instantly share code, notes, and snippets.

@pseudokool
Created September 11, 2018 17:05
Show Gist options
  • Save pseudokool/c7707937f075dd74cfa905edc80de39b to your computer and use it in GitHub Desktop.
Save pseudokool/c7707937f075dd74cfa905edc80de39b to your computer and use it in GitHub Desktop.
Desktop (GUI) mode for Ubuntu 16.04 on AWS EC2

Ubuntu 16.04 on AWS EC2

This guide enables desktop mode in Ubuntu 16.04 (Xenial Xerus) running off an AWS EC2.

Setup

  • Launch an EC2 instance with Ubuntu 16.04 (should work on all versions greater too)
  • Ensure a security group is configured, that allows ingress on ports 22 (SSH) and 5901 (VNC, 5900+N, where N is the display number)
  • SSH into the instance, update the system, install the XFCE desktop and the lightweight VNC server:
sudo apt-get update
sudo apt install xfce4 xfce4-goodies tightvncserver
  • Now, initialize. Assign a password to login in via remote desktop. Finally, kill VNC server.
vncserver
vncserver -kill :1
  • To reconfigure VNC:
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
nano ~/.vnc/xstartup
  • Add in the following to the xstartup config.
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
  • Make xstartup an executable script and start the VNC server
sudo chmod +x ~/.vnc/xstartup
vncserver

Connecting to the instance

Once setup is complete, you can remote desktop into your instance with GUI.

  • On OS X, use screen sharing
vnc://<instance_ip>:5901
  • On Linux, use krdc, remmima etc

References

@pseudokool
Copy link
Author

@benjaminv much thanks. My initial setup was on LightSail too, but needed a tighter knit setup with other vpc services, hence the switch.

@tcchau
Copy link

tcchau commented Aug 9, 2023

For my particular Lightsail instance, I ran into the following error re: dbus-launch after connecting with VNC. To resolve it, I installed dbus:

sudo apt install dbus-x11

Also, note that dbus-x11 has to be installed before vncserver is started, if you're going through this the first time.

OS details:

cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

This was on a node.js template on AWS Lightsail.

@pseudokool
Copy link
Author

For my particular Lightsail instance, I ran into the following error re: dbus-launch after connecting with VNC. To resolve it, I installed dbus:

sudo apt install dbus-x11

Noted. Could you share OS version details?

@tcchau
Copy link

tcchau commented Aug 10, 2023

For my particular Lightsail instance, I ran into the following error re: dbus-launch after connecting with VNC. To resolve it, I installed dbus:

sudo apt install dbus-x11

Noted. Could you share OS version details?

Sure, I edited my comment to include details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment