Linux RDP Servers and Desktop Sharing

Contents

1. 

XRDP

1.1. 

XRDP --- Introduction

Notes:

  1. Available packaged for, and works on, any major Linux distro?
  2. N.B. xrdp provides a virtual desktop — it does not give access to your console desktop.
  3. BAD THINGS may happen if you try to connect using xrdp to the same user as using the console desktop --- you may connect only to a blank/black screen and possibly you may break the console session (depends on what session/environment is running).
  4. If you want access to your console desktop, use Gnome desktop sharing.
  5. xrdp provides a stateful desktop — you can disconnect and reconnect to the same session with the same applications left running between connections.

Installation:

e.g.,

    apt-get install xrdp
. You will probably need this too:
    adduser xrdp ssl-cert
    systemctl restart xrdp
Then, to check all is well:
    systemctl status xrdp -n50

1.2. 

XRDP Works Out of the Box on Localhost

A simple, easy, test to start with: try making it work on your localhost (127.0.0.1). I will use xrdp with user simonhtoo — with simonh on the console desktop. We will test with a relatively light-weight environment/session — XFCE4. Install

    apt-get install xfce4
and set up simonhtoo to use it: cat /home/simonhtoo/.xsession:
    #!/bin/sh

    /usr/bin/xfce4-session

Then connect using the RDP client, Vinaigre, using the following settings:

 -- 127.0.0.1
 -- 1920x1080 
 -- Xorg
 -- username:  simonhtoo

Once logged in:

Works out of the box! But, N.B.

    systemctl status xrdp -n50
    .    .
    ERROR Cannot read private key file /etc/xrdp/key.pem: Permission denied
But does not seem to matter, presumably because on localhost.

1.3. 

XRDP Needs that SSL Tweak for Real Examples

On a remote host, which you want to be an RDP server, ensure xrdp is installed and then

    adduser xrdp ssl-cert
    systemctl restart xrdp
Without this you will be able to apparently connect but likely get a blank/black screen. By way of diagnostics, on the remote box, after such an event
    systemctl status xrdp -n50
    .    .
    ERROR Cannot read private key file /etc/xrdp/key.pem: Permission denied

With this happily in place, you will get a certificate verification dialogue box on the Vinagre client --- accept assuming it is right!

Remember to use a different user from that logged into the console desktop!

1.4. 

Troubleshooting

If a xrdp session for a particular user (e.g., simonhtoo) is messed up then new connections do not work — e.g. black screen. Solution: SSH into the remote host and

  ps axo user:20,pid | grep simonhtoo | awk '{print $2}' | xargs -i{} kill {}
...and start again!

1.5. 

XRDP and Cinnamon

/home/simonhtoo/.xsession:

    #!/bin/sh

    /usr/bin/cinnamon-session

2. 

Virtual Box

 -- VirtualBox VM RDP server built-in!  Try it!
 -- VirtualBox VM RDP server built-in!  Try it!

3. 

Gnome Remote Desktop and Desktop Sharing

The Gnome desktop environment includes its own RDP support which is easier to set up than xrdp — provided you use Gnome of course. It also includes desktop sharing — i.e., you can share the console desktop remotely. Gnome is the standard desktop environment with Ubuntu Linux.

The following is based on an Ubuntu 24.04 Gnome/RDP server and Mint 22.1 RDP client. The server is in a VirtualBox VM; Mint is the host OS.

N.B. If you have been playing with xrdp (as above), before attempting the things outlined below, you will need to disable it — you cannot have two things listening on the same port:

    systemctl stop xrdp
    systemctl disable xrdp

3.1. 

Gnome Remote Login Configuration

  1. Open the Settings app and, on the left, scroll down if needed, to the bottom and select System..
  2. From the options in that appear, choose Remote Login.
  3. Toggle the switch to "on" and note the port number — see image below (standard port for RDP, 3389, in this case).
  4. Do not forget to set login credentials.



Gnome Remote Login Configuration




Note the port number: 3389, standard for RDP.


3.2. 

Gnome Desktop Sharing Configuration

  1. At the top, select Desktop Sharing.
  2. Toggle both Desktop Sharing and Remote Control to "on".
  3. Note the port number — 3390 in this case, which must be used in place of 3389 for the desktop sharing functionality. See image below.
  4. Do not forget to set login credentials.



Gnome Desktop Sharing Configuration




Note the port number: 3390, NON-standard for RDP


3.3. 

Testing Gnome Remote Login and Desktop Sharing

  1. Open up a terminal and type netstat -ltnp – there should be something listening on both 3389 and 3390 (or whatever ports you got above).
  2. Using the Remmina client, enter <vm guess ip>:3389 and hit return. An Ubuntu login window appears. After authentication two options appear: session already running: cancel or force stop. This is as expected — this is not the sharing port.
  3. Using the Remmina client, enter <vm guess ip>:3390 and hit return. After authentication, the same desktop as on the VM console appears! Typing in the terminal in either Remmina client or on the VM console echoes in the other! See the image below.
  4. N.B. I found that the Linux RDP client Vinagre on my Mint host would connect to the RDP server running on the VM guest, failed to authenticate. Attempting to diagnose I started it from the command line to see the stuff coming out of stderr:
         -- protocol errors
             -- ERRCONNECT_CONNECT_TRANSPORT_FAILED



Gnome Desktop Sharing in Action




The RDP server is in a VirtualBox window to the left: You can see Firefox and a terminal in a standard Ubuntu 24.04 Gnome environment. To the right (foreground) is a Remmira RDP client desktop running on the host Mint Linux: you can see the same desktop! N.B. The correct port number, in this case 3390, must be specified: you can just see this in the top of the Remmira connection dialogue box, which is behind the Remmira client desktop, highlighted in green.