The most common use for a VPS is that of a server, a host that provides a specific functionality, be it a web or a mail server. However, VPSes can also play the role of a remote desktop. It would be useful to have a remote desktop that you can develop on without having to worry about syncing your code, setting up IDEs across multiple workstations. Today, we will explore how to install a desktop GUI on your VPS
Ideally, you should start with a brand new VPS, but there is nothing that prevents you from doing this on an existing VPS. A word of warning though, it is possible that you may lose connection to your VPS once the desktop is installed, so try this on a VPS that you are okay re-installing.
In terms of specs, we do not need a really powerful VPS, a 512MB RAM VPS should be okay. I am using a 1GB VPS. Finally, the guide is for Ubuntu as this flavor seems to do better than others to install a desktop UI on. The version in this article is Ubuntu 16.04 LTS. There are a number of UIs we can choose from - GNOME, XFCE and LXDE. Amongst these, GNOME is more resource hungry than the others. We will install XFCE desktop through this article (this desktop environment is available for Debian/CentOS and Fedora distributions as well)
All the below steps are executed as a non-root user with sudo privileges. First, let us update the packages on the server via apt-get
$ sudo apt-get update
$ sudo apt-get upgrade
Since the purpose of the VPS is primarily that of a desktop, let us remove unwanted packages such as apache2, sendmail etc.
$ sudo apt-get remove --purge -y apache2* bind9* sendmail* samba* && sudo apt-get
-y autoremove && sudo apt-get -y upgrade
We will install xfce, xfonts, vncserver and xrdp for the desktop and establishing connectivity.
$ sudo apt-get -y install xfce4 xfonts-base tightvncserver xrdp
You may encounter messages asking you to choose the language and keyboard settings like the below
Once the installation is complete, you can connect to the machine via RDP (see the next session for ways to connect). Here below is the first welcome screen. Graphics quality is pretty decent, but then this is the lightweight version.
By running top on the server, you can see that the load is low, though this is a machine where I am not running anything.
Memory usage is also low, here is the output from free -m
total used free shared buff/cache available
Mem: 1024 130 0 44 893 760
Swap: 0 0 0
(I also realize, I have not setup swap on my VPS, something I will rectify soon)
You are now free to install other packages. Here, I am installing firefox
You can add other packages. During the course of my install & testing, I found the desktop to be quite responsive. Of course, more the running applications, the better your performance with increased RAM. Quite possibly, a 4GB VPS with low latency would be as good as a local Linux desktop.
We have installed xrdp which allows connectivity using Remote Desktop Protocol (RDP). On Windows, you can use the inbuilt Remote Desktop Connection application. Enter the IP address of your VPS and the connection should go through. On Linux, you can install the feature rich Remmina (which also acts as a SSH client). I am not familiar with Mac, but there is a paid app called Jump Desktop. For a free solution (across OSes), you could install the Chrome add-on - Chrome Remote Desktop
Hope you now have a solution for a remote desktop that you can use from anywhere and no longer worry about machine specific idiosyncrasies or synching data from one location to another.