While this guide applies to Linux distributions in general, the commands and package names shown here are specifically for Debian/Ubuntu servers and desktops. In most cases, you’ll just have to adapt the apt command and package name for your distribution if you’re not on a Debian based system.

Many guides do two things wrong:

  • They install a full-blown desktop on your server, which is overkill.
  • They install a VNC server and use it as RDP backend, which is stupid.

Why the things other guides do are bad:

  • Installing a full-blown desktop environment on your server is too much, as it will effectively turn your server into a desktop, with login greeter, pulseaudio, bloatware, and possibly freakin’ solitaire! Do you want this for your server? Even if you use tasksel and choose a “mininmal” desktop, it’s still too much.
  • Installing VNC as backend defeats the whole point of RDP. You see, RDP and VNC work completely differently: RDP is meant for real remote desktop from client to server, where the client chooses the screen resolution and the server transmits draw commands. The screen is rendered on the client, so to speak. VNC on the other hand streams images of your current session, which is what VNC will connect to and what will determine the screen resolution. But since we’re not going to turn a server into a desktop, VNC wouldn’t even work.
  • Note that there’s one use case where a VNC backend makes sense: If it’s an actual desktop computer that already uses a VNC server and you just want to add RDP on top so that Windows users can connect to it without having to install an additional VNC client and instead use the built-in RDP client.

What we’ll be doing instead:

We’ll be installing a virtual display, keyboard and mouse driver which will be controlled by RDP. This way, our client will determine screen resolution and the server will be sending draw commands, the way RDP is meant to be. Each time we connect to RDP a new X session will be started according to the client’s parameters. Furthermore, if your internet connection allows it, it will be so fast you will be able to watch videos through RDP!

We’ll also be putting together our own mini-desktop which will give us just what we need on a server.

Getting started:

We need to install two packages, the virtual display/keyboard/mouse drivers and the RDP server itself.

But first, what driver we’ll be installing depends on your Ubuntu Server version and whether it’s using the HWE kernel or not. If you’re not on HWE you’ll simply install:

sudo apt install xorgxrdp xrdp

If you’re on Ubuntu 18.04 with HWE kernel you’ll instead install:

sudo apt install xorgxrdp-hwe-18.04 xrdp

xorgxrdp is the driver package for the virtual screen, keyboard and mouse whereas xrdp is the actual RDP server.

Installing things for the mini desktop

For our mini desktop we’ll be using Openbox as the window manager, one that’s for example used by the LXDE desktop. However, we won’t install a desktop on top of it. Instead, we’ll be putting it together ourselves.

sudo apt install openbox

If we were to restart xrdp now and connect, we’d be getting a boring black screen. But we want a task bar and perhaps a desktop wallpaper to show off what we can do, and to not get too depressed by a black screen.

For our taskbar we’ll be using tint2 and we’ll be using hsetroot to change the desktop background:

sudo apt install tint2 hsetroot

And for wallpapers, assuming we’re on Ubuntu 18.04 Bionic:

sudo apt install ubuntu-wallpapers-bionic

Now we need to put things together to make our desktop!

Putting the mini desktop together

Now we’ll be editing the Openbox autostart file to start the taskbar and set the desktop background. Use your favorite editor like nano:

sudo nano /etc/xdg/openbox/autostart

And insert the following:

hsetroot -cover /usr/share/backgrounds/Beaver_Wallpaper_Grey_4096x2304.png &
tint2 &

Hit CTRL + S to save and CTRL + X to exit nano.

We can now restart xrdp so it will be aware of openbox and the xinitrc:

sudo systemctl restart xrdp

Installing basic applications

While in theory we’re done here, we still want some basic applications like a terminal emulator and a file browser and a web browser. But we want the minimal possible!

For our terminal needs we’ll be using xterm, and for the file browser we’ll be using xfe which is minimal but enough and is reminiscent of the Windows Explorer. Xfe also includes a minimal text editor and image viewer. For the browser we could use something minimal like midori but I’ll go for Firefox this time:

sudo apt install xterm xfe firefox

Installing the RDP client

On the client side, we’ll be installing Remmina with the RDP plugin like so:

sudo apt install remmina-plugin-rdp

SSH Tunnel

Now, if you’ll just be using this on your trusted intranet, all is done and ready but since TLS support isn’t that great yet on the FOSS RDP side, if you want to connect through the internet you should be using an SSH tunnel. Remmina can do this for you, but in my case I use a hardware security key which doesn’t work with Remmina, so I’ll be showing you how to manually set up the SSH tunnel:

ssh -L 3389:127.0.0.1:3389 username@server

This will connect to your server through SSH, and create a local listener at port 3389 (the default RDP port) and forward all incoming connections through SSH to (from the server perspective) to localhost on port 3389.

Connecting with Remmina

Start Remmina, click on the plus and set the name to something like “Localhost SSH” choose RDP as protocol and set the server to localhost and then RemoteFX as color depth. For resolution, assuming you want full screen, click on the three dots right to the selector and add your desktop resolution and choose that. Now click save.

Note: If your SSH server is using password or keyfile authentication you can instead configure the SSH tunnel in the SSH tunnel tab. However, password authentication is discouraged.

Double-click on the saved connection to connect. If you can’t see it, sometimes Remmina bugs. Close and re-open Remmina. After connecting you will see something like a login window. For session choose Xorg and just enter the username and password of the server’s user you want to connect as (the same one we set up Openbox for).

And now you should be logged in to your shiny new, minimal desktop! To start applications, right click on the desktop to bring up the Openbox menu.

Conclusion

And this is how you do it the right way, without bloat (except for the wallpaper).

Of course, you can now configure xrdp to require network level authentication and tweak things to your liking but I just wanted to give you the basics on how to properly set up an RDP server on Ubuntu without a full desktop or other bloat, or nonsense VNC backend.

And that’s all there is to it!

Notes

I noticed on Ubuntu Server 20.04 the package xorgxrdp seems to install a full-blown desktop which is madness and should probably be reported as a bug… On Ubuntu Server 18.04 it does not, however.