Remote Desktop on Ubuntu
Introduction
xrdp is a free and open-source implementation of the Microsoft RDP (Remote Desktop Protocol) server,
which lets operating systems other than
Microsoft Windows
(such as
Linux
and
operating systems in the style of
BSD
), provide a fully functional RDP-compatible
remote desktop.
It works by connecting the graphics from the X Window system to the client and relaying control
input from the client back to
X
.
According to the developers, the protocol works with rdesktop, FreeRDP and Microsoft's own
remote desktop client
Installation
To use xrdp you must first install X server . For example, Gnome or Xfce.
Install Gnome:
sudo apt update
sudo apt install ubuntu-desktop
Install xfce:
sudo apt update
sudo apt install xubuntu-desktop
sudo apt install xrdp
Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: xorgxrdp Suggested packages: guacamole xrdp-pulseaudio-installer The following NEW packages will be installed: xorgxrdp xrdp 0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded. Need to get 488 kB of archives. After this operation, 3,212 kB of additional disk space will be used. Do you want to continue? [Y/n]
Y
Check the status
sudo systemctl status xrdp
● xrdp.service - xrdp daemon Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-01-19 15:21:51 EET; 5min ago Docs: man:xrdp(8) man:xrdp.ini(5) Main PID: 188751 (xrdp) Tasks: 1 (limit: 38009) Memory: 1.9M CGroup: /system.slice/xrdp.service └─188751 /usr/sbin/xrdp Jan 17 15:21:50 andrei xrdp[188750]: (188750)(139708266788672)[INFO ] address [0.0.0.0] port [3389] mode 1 Jan 17 15:21:50 andrei xrdp[188750]: (188750)(139708266788672)[INFO ] listening to port 3389 on 0.0.0.0 Jan 17 15:21:50 andrei xrdp[188750]: (188750)(139708266788672)[INFO ] xrdp_listen_pp done Jan 17 15:21:50 andrei xrdp[188750]: (188750)(139708266788672)[DEBUG] Closed socket 7 (AF_INET6 :: port 3389) Jan 17 15:21:50 andrei systemd[1]: xrdp.service: Can't open PID file /run/xrdp/xrdp.pid (yet?) after start: Operation > Jan 17 15:21:51 andrei systemd[1]: Started xrdp daemon. Jan 17 15:21:52 andrei xrdp[188751]: (188751)(139708266788672)[INFO ] starting xrdp with pid 188751 Jan 17 15:21:52 andrei xrdp[188751]: (188751)(139708266788672)[INFO ] address [0.0.0.0] port [3389] mode 1 Jan 17 15:21:52 andrei xrdp[188751]: (188751)(139708266788672)[INFO ] listening to port 3389 on 0.0.0.0 Jan 17 15:21:52 andrei xrdp[188751]: (188751)(139708266788672)[INFO ] xrdp_listen_pp done
Restart xrdp
sudo systemctl restart xrdp
Clients
Remmina
sudo apt install remmina
Errors
Cannot read private key file /etc/xrdp/key.pem: Permission denied
You ran
sudo systemctl status xrdp
And got the error
Cannot read private key file /etc/xrdp/key.pem: Permission denied
Run
ls -la /etc/xrdp/
total 332 drwxr-xr-x 3 root root 4096 Jan 19 15:21 . drwxr-xr-x 142 root root 12288 Feb 4 13:51 .. lrwxrwxrwx 1 root root 36 Jan 19 15:21 cert.pem -> /etc/ssl/certs/ssl-cert-snakeoil.pem lrwxrwxrwx 1 root root 38 Jan 19 15:21 key.pem -> /etc/ssl/private/ssl-cert-snakeoil.key …
lrwxrwxrwx tells us that this file has no restrictions at all, but the type of this file is a link so we follow it to where it points
sudo -i ls -la /etc/ssl/private/
total 12 drwx--x--- 2 root ssl-cert 4096 Dec 11 14:51 . drwxr-xr-x 4 root root 4096 Dec 11 15:12 .. -rw-r----- 1 root ssl-cert 1708 Dec 11 14:51 ssl-cert-snakeoil.key
-rw-r----- means that the owner of the file can read and write, and members of the group can read.
The group is called ssl-cert
Let's add xrdp to this group and check
sudo usermod -G ssl-cert xrdp
groups xrdp
xrdp : xrdp ssl-cert
Now xrdp is a member of the ssl-cert group and must be able to read the file ssl-cert-snakeoil.key
sudo systemctl restart xrdp
xfreerdp
Connect to the host by IP and user name.
xfreerdp /v:192.168.0.2 /u:andrei
Additionally specify the port
xfreerdp /v:192.168.0.2 /u:andrei /t:9119
Connect through an intermediary
We connect to 10.1.100.200 via andrei.server.com
xfreerdp /v:andrei.server.com /u:"tester|10.1.100.200|serv_user" /p:Password
Article author: Andrei Olegovich