Virtual Linux Remote Desktop

Have you ever wanted a persistent Linux virtual desktop that you could host anywhere and access remotely? Now you can do it, using only Ubuntu and a cheap VPS!

I like having deterministic work environments. Disaster recovery becomes a cinch when you can just destroy and rebuild your desktop container, map your home directory back in, and continue working.

How it Works

There are remote desktop packages that can operate on top of a purely software X window stack. We can leverage that to run in a container, where there is no hardware to access. All we need to do is install the desktop environment, and then set up the remote desktop software. This setup works in containers, virtual machines, even bare metal.

I’ll be using Ubuntu as my base operating system, but it should be doable in other distributions as well.

Baseline Setup

The desktop environment will attempt to install bluetooth, which will break things. We pre-emptively install and disable it:

1sudo apt update
2sudo apt install -y bluez
3sudo systemctl disable bluetooth

You’ll need some preliminary tools installed:

1sudo apt install -y software-properties-common openssh-server locales tzdata debconf

Desktop Environment

Next, choose a desktop environment. Due to dbus issues, only mate and lxde desktop environments work when installed this way.

1sudo apt install -y ubuntu-mate-desktop


1sudo apt install -y lubuntu-desktop

This step will take awhile!

Configure for GUI Use

light-locker will interfere with remote desktop software, so remove it if it got installed:

1sudo apt remove -y light-locker

Here are some services we don’t need to have running:

1sudo systemctl disable apport
2sudo systemctl disable cpufrequtils
3sudo systemctl disable hddtemp
4sudo systemctl disable lm-sensors
5sudo systemctl disable network-manager
6sudo systemctl disable speech-dispatcher
7sudo systemctl disable ufw
8sudo systemctl disable unattended-upgrades

Some other things you may want to set up:


1sudo timedatectl set-timezone "America/Vancouver"


1sudo locale-gen en_US en_US.UTF-8
2sudo update-locale LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8

Keyboard Layout:

1echo "keyboard-configuration keyboard-configuration/layoutcode string us" | sudo debconf-set-selections
2echo "keyboard-configuration keyboard-configuration/modelcode string pc105" | sudo debconf-set-selections

Add a User

Depending on whether you’re using lxc or multipass or some other virtualization system, you may already have a user set up such as “ubuntu”. I prefer to set up my own user, like so:

1sudo useradd -m -s /bin/bash -U -G adm,sudo mynewuser
2echo mynewuser:mynewpassword | sudo chpasswd

Remember to set up allowed keys for the user if you have any.

Remote Desktop Software


X2Go is the easiest to set up. It works over ssh, which is nice and convenient, but requires a direct connection. I prefer to grab the latest from the PPA, but the default may work for you as well.

1sudo add-apt-repository -y ppa:x2go/stable
2sudo apt install -y x2goserver x2goserver-xsession x2goclient

X2Go uses ssh for communication. You’ll need to either set up allowed keys, or just for testing you could enable password authentication:

1sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
2sudo service ssh restart

Chrome Remote Desktop

This is purely optional. You’ll still need X2Go installed to be able to set up Chrome Remote Desktop.

First, download and install the debs:

3sudo apt install -y ./google-chrome-stable_current_amd64.deb ./chrome-remote-desktop_current_amd64.deb

Chrome Remote Desktop will use a default screen resolution of 1600x1200, which is the wrong aspect ratio, and will result in black bands on the sides when you go fullscreen. We can just change it to whatever we want, for example 1920x1080:

1sudo sed -i 's/DEFAULT_SIZE_NO_RANDR = "[0-9]*x[0-9]*"/DEFAULT_SIZE_NO_RANDR = "1920x1080"/g' /opt/google/chrome-remote-desktop/chrome-remote-desktop

Now you’ll need to log in to the remote desktop via X2Go. You can get your virtual machine’s ip address using ip addr, then log in as the user you created earlier.

Note: You may need to resize the virtual screen to see the menu bar.

Inside the X2Go remote desktop, do the following:

  • Launch Chrome
  • Sign in
  • Turn on sync (or go to settings to selectively sync - even disable everything if you want)
  • Go to the chrome store and install Chrome Remote Desktop
  • Launch Chrome Remote Desktop and enable connections to your computer.

You should now be able to see and log in to your virtual desktop using Chrome Remote Desktop.


Setting up a virtual desktop is a bit involved, but once you know what needs to be done, it’s not too hard to write up a script that does this automatically. I do exactly that in my Ubuntu dev environment installer .

Happy hacking!

Introduction to High Availability
Line Lengths