Linux RDP Servers and Desktop Sharing
Contents
1. |
XRDP |
1.1. |
XRDP --- Introduction |
Notes:
- Available packaged for, and works on, any major Linux distro?
- N.B. xrdp provides a virtual desktop — it does not give access to your console desktop.
- 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).
- If you want access to your console desktop, use Gnome desktop sharing.
- 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 xrdpThen, 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 xfce4and 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:
- start some apps;
- disconnect and reconnect --- stateful!
Works out of the box! But, N.B.
systemctl status xrdp -n50 . . ERROR Cannot read private key file /etc/xrdp/key.pem: Permission deniedBut 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 xrdpWithout 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 |
- Open the Settings app and, on the left, scroll down if needed, to the bottom and select System..
- From the options in that appear, choose Remote Login.
- Toggle the switch to "on" and note the port number — see image below (standard port for RDP, 3389, in this case).
- Do not forget to set login credentials.
3.2. |
Gnome Desktop Sharing Configuration |
- At the top, select Desktop Sharing.
- Toggle both Desktop Sharing and Remote Control to "on".
- Note the port number — 3390 in this case, which must be used in place of 3389 for the desktop sharing functionality. See image below.
- Do not forget to set login credentials.
3.3. |
Testing Gnome Remote Login and Desktop Sharing |
- Open up a terminal and type netstat -ltnp – there should be something listening on both 3389 and 3390 (or whatever ports you got above).
- 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.
- 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.
- 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