Usually, Linux-based servers don’t come with a graphical user interface (GUI) pre-installed. Whenever you want to run GUI applications on your instance, the typical solution is to employ Virtual Network Computing (VNC). Unfortunately, VNC solutions can be sluggish and insecure; many also require a lot of manual configuration. By contrast, X2Go provides a working “cloud desktop,” complete with all the advantages of an always-online, remotely-accessible, and easily-scalable computing system with a fast network. It is also more responsive and more secure than many VNC solutions.
In this tutorial, you’ll use X2Go to create an XFCE desktop environment that you can access remotely.
The setup described in this tutorial is useful when:
Before starting this tutorial, you’ll need:
A CentOS 8 x64 instance with 2GB of RAM or more. 2GB is minimal, but a server with 4GB or more is ideal if you have memory-hungry applications that you plan to run. You can use a DigitalOcean Droplet if you like.
A user with
sudo privileges and an SSH key. Follow this guide to get started: Initial Server Setup with CentOS 8. At Step 4, configure the firewall as instructed, but don’t enter the command
firewall-cmd --permanent --add-service=http. This command opens post
80 on your server, which you don’t need.
With your server up and your firewall configured, you are now ready to install the graphical environment.
First, upgrade all software packages on your instance:
- sudo dnf upgrade
In this tutorial, you are installing XFCE as the desktop environment. XFCE doesn’t use graphical effects like compositing, making it more compatible with X2Go and allowing it to optimize how screen updates are sent across the network. In other words, it’s probably the easiest one to get working with X2Go since everything immediately works well out of the box. LXDE should also work out of the box. MATE and KDE desktop environments might work too, but some workarounds might be needed, for example, disabling compositing to improve performance and responsiveness.
If you prefer a different desktop environment, you would have to replace a command such as
sudo dnf groupinstall Xfce from this tutorial with
sudo dnf group install "KDE Plasma Workspaces" to install
KDE, and then configure the Session type in your X2Go client to KDE. You can also install multiple desktop environments, alongside each other, and then pick the one you prefer to launch, each time you log in with your X2Go client.
The software packages you now need to install aren’t contained in CentOS’ default repositories, so you have to enable the Extra Packages for Enterprise Linux (EPEL) repositories:
- sudo dnf install epel-release
Some X2Go server utilities also depend on some packages found in the PowerTools repository, which you can enable with the next command:
- sudo dnf config-manager --set-enabled PowerTools
Finally, you can now install the XFCE desktop environment:
- sudo dnf groupinstall Xfce
CentOS offers a rather minimal XFCE environment, but you can add any other utilities you need (e.g., web browsers, image editors) with simple
sudo dnf install name_of_application commands.
With the desktop environment now installed, it’s time to establish a way to view it on your local computer.
X2Go comes with two main components: the server, which starts and manages the graphical session on the remote machine, and the client, which you install on your local computer to view and control the remote desktop or application.
To install X2Go on your server, type the following command:
- sudo dnf install x2goserver
At this point, your server requires no further setup. However, keep in mind that if you followed the recommendation of setting up SSH keys in the Initial Server Setup with CentOS 8, then you will need to have your SSH private key available on every local machine that you intend to log in from, to your remote desktop session. If you didn’t set up an SSH private key, make sure you choose a strong password.
Note: Remember that if you run out of RAM, the Linux kernel might abruptly terminate some applications, resulting in lost work. If you are using a DigitalOcean Droplet and you notice that your programs require more RAM, you can temporarily power off your Droplet and upgrade (resize) to one with more memory.
You have configured your server. Type
exit or close your terminal window. The rest of the steps will focus on configuring the client on your local machine.
X2Go is ready to use out of the box. If you’re using Windows or macOS on your local machine, you can download the X2Go client software here. If you’re using Debian or Ubuntu you can install the X2Go client with this command on your local machine:
- sudo apt-get install x2goclient
After downloading the software, you are ready to install it. Open the installer and select your preferred language. Now agree to the license and let the wizard guide you through the remaining steps. Typically, there shouldn’t be any reason to change the pre-filled, default values in these steps.
X2Go works well out of the box, but it is also highly customizable. If you’d like additional information, visit X2Go’s official documentation.
Now that you have installed the desktop client, you can configure its settings and connect to the X2Go server to use your remote XFCE desktop.
When you first open the X2Go client, a window will appear. If it doesn’t, click Session in the top-left menu and then select New session ….
In the Session name field, enter something to help differentiate between servers. Using a session name is particularly useful if you plan on connecting to multiple machines.
Enter your server’s IP address or a fully qualified domain name (FQDN) in the Host field under Server.
Enter the username you used for your SSH connection in the Login field.
Since you installed XFCE in Step Two, choose
XFCE as your Session type.
Finally, because you connect to the server with SSH keys, click the folder icon next to Use RSA/DSA key for ssh connection and browse to your private key. If you didn’t opt to use the more secure SSH keys, leave this empty; the X2Go client will ask for a password each time you log in.
The rest of the default settings will suffice for now, but as you get more familiar with the software, you can fine-tune the client based on your individual preferences.
After pressing the OK button, you can start your graphical session by clicking the white box that includes your session’s name on the box’s top-right side.
If you are running OS X on your local machine, OS X might prompt you to install XQuartz, which is required to run X11. If so, follow the instructions to install it now.
In a few seconds, your remote desktop will appear, and you can start interacting with it.
There are a few useful keyboard shortcuts you can use for a better experience on Windows and Linux-based operating systems.
Note: These first two options can exhibit buggy behavior on modern Windows editions. You can still test them at this point, in case later versions of X2Go fix the issues. If they fail, just avoid using the same keyboard shortcut in the future.
CTRL+ALT+F will toggle full-screen mode on and off. Working in full-screen mode can feel more like a local desktop experience. The full-screen mode also helps the remote machine grab keyboard shortcuts instead of your local machine.
CTRL+ALT+M will minimize the remote view, even if you are in full-screen mode.
CTRL+ALT+T will disconnect from the session but leave the GUI running on the server. It’s just a quick way of disconnecting without logging off or closing applications on the server. The same will happen if you click the window’s close button.
Lastly, there are two ways you can end the remote session and close all of the graphical programs running in it. You can log off remotely from XFCE’s start menu, or you can click the button marked with a circle and a small line (like a power/standby icon) in the bottom-right corner of the main portion of the X2Go screen.
The first method is cleaner but may leave programs like session-managing software running. The second method will close everything but may do so forcefully if a process can’t exit cleanly. In either case, be sure to save your work before proceeding.
You have now successfully accessed and configured your remote desktop.
In this tutorial, you used X2Go to create a robust and remote GUI-environment for the CentOS operating system. Now that you are up and running, here are a few ideas about using this desktop:
localhostin the address bar, you can test the web application you are working on, without having to constantly re-upload files to some remote server. And everything is encapsulated within the secure and private SSH connection used by X2Go to view your remote desktop. This means that although you are testing your website on a server connected to the Internet, the web app you are working on can only be viewed by you, it is not publicly accessible, so you don’t have to worry about accidentally leaking unfinished and unpolished work.
All in all, you can create a complete development environment, with all the bells and whistles, from the code editor you use, to the software required to run and test that code.
If you’d like to learn more, visit X2Go’s official documentation website.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.