In this guide, we will look at an example of installing and configuring an X2Go server to remotely connect to a server running Ubuntu 18.04 or Centos 7.7.

Using X2Go implies an already installed graphical environment, if this has not already been done, the first thing you need to install one of such shells as for example XFCE, LXDE, or MATE.

Ubuntu 18.04

Installing XFCE
# apt-get install xfce4
Installing LXDE
# apt-get install lxde
Installing MATE
# apt-get install mate-core mate-desktop-environment mate-notification-daemon
Install X2Go

We need to add a link to the PPA for X2Go, but the add-apt-repository command may not be available on your server. To fix this, run the following command:

# apt-get install software-properties-common

Now add the PPA X2Go:

# add-apt-repository ppa: x2go / stable

Then update the database of available software packages by doing:

# apt-get update

Now we can install X2Go by running:

# apt-get install x2goserver x2goserver-xsession

Another thing we need to do before connecting is to edit /root/.profile. The reason for this is that if you leave it as it is, we will receive the following error when trying to connect to Remote Desktop:

To fix this, connect via SSH to your server and edit the /root/.profile file using your preferred text editor.
At first, it looks like this:

We just need to change the last line by adding tty -s && at the beginning of the last line. It should look like this:

After that, save and close the file.

Centos 7.7

Installing XFCE
# yum groupinstall -y "Xfce"
# yum install x2goserver x2goserver-xsession

Installing MATE
# yum groupinstall "MATE Desktop"
# yum install x2goserver x2goserver-xsession

Launch the X2Go client on your local computer. At the first start, you should see the following window where you create a session. If you don’t see it, create a new session by clicking on the “Session” → “New Session” menu in the upper left menu.

In the Session Name field, you can name your session for easy access.
In the Host field, enter the name or IP address of your server.
In the Login field, enter the username that you used to connect via SSH.
In the Session Type drop-down list, select the option that matches your desktop environment.
Click OK to save the session.

You now have the remote desktop of your server.