Ubuntu: How to use xrdp remote access


Step 1: Install XRDP

root@tutorialspots:~# sudo apt-get install xrdp -y
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 10 not upgraded.
Need to get 488 kB of archives.
After this operation, 3,212 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 xrdp amd64 0.9.12-1 [428 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 xorgxrdp amd64 1:0.2.12-1 [59.9 kB]
Fetched 488 kB in 0s (2,365 kB/s)
Selecting previously unselected package xrdp.
(Reading database ... 144142 files and directories currently installed.)
Preparing to unpack .../xrdp_0.9.12-1_amd64.deb ...
Unpacking xrdp (0.9.12-1) ...
Selecting previously unselected package xorgxrdp.
Preparing to unpack .../xorgxrdp_1%3a0.2.12-1_amd64.deb ...
Unpacking xorgxrdp (1:0.2.12-1) ...
Setting up xrdp (0.9.12-1) ...

Generating 2048 bit rsa key...

ssl_gen_key_xrdp1 ok

saving to /etc/xrdp/rsakeys.ini

Created symlink /etc/systemd/system/multi-user.target.wants/xrdp-sesman.service → /lib/systemd/system/xrdp-sesman.service.
Created symlink /etc/systemd/system/multi-user.target.wants/xrdp.service → /lib/systemd/system/xrdp.service.
Setting up xorgxrdp (1:0.2.12-1) ...
Processing triggers for systemd (245.4-4ubuntu3.11) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...

Step 2: Install xfce
Ubuntu: how to install xfce Desktop

Step 3 – Configure xRDP

In this step, we create 2 new files: ~/startwm.sh and ~/.xsession

sudo su - tutorialspots
vi ~/startwm.sh

Content:

#!/bin/sh

if [ -r /etc/default/locale ]; then
  . /etc/default/locale
  export LANG LANGUAGE
fi

startxfce4
chmod a+x ~/startwm.sh
echo xfce4-session > ~/.xsession

Step 4: edit file /etc/xrdp/xrdp.ini
Switch to root account

vi /etc/xrdp/xrdp.ini

Content:

...
; security layer can be 'tls', 'rdp' or 'negotiate'
; for client compatible layer
security_layer=rdp

; minimum security level allowed for client for classic RDP encryption
; use tls_ciphers to configure TLS encryption
; can be 'none', 'low', 'medium', 'high', 'fips'
crypt_level=none
...

config xrdp ini

Step 5:

root@tutorialspots:~# systemctl enable xrdp
Synchronizing state of xrdp.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable xrdp
root@tutorialspots:~# systemctl start xrdp

Check status:

root@tutorialspots:~# systemctl status xrdp
● xrdp.service - xrdp daemon
     Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: >
     Active: active (running) since Sun 2021-08-22 22:21:10 +07; 13min ago
       Docs: man:xrdp(8)
             man:xrdp.ini(5)
   Main PID: 32550 (xrdp)
      Tasks: 1 (limit: 9279)
     Memory: 1.1M
     CGroup: /system.slice/xrdp.service
             └─32550 /usr/sbin/xrdp

Aug 22 22:21:09 123 xrdp[32549]: (32549)(140015163086656)[INFO ] address [0.0.0>
Aug 22 22:21:09 123 xrdp[32549]: (32549)(140015163086656)[INFO ] listening to p>
Aug 22 22:21:09 123 xrdp[32549]: (32549)(140015163086656)[INFO ] xrdp_listen_pp>
Aug 22 22:21:09 123 xrdp[32549]: (32549)(140015163086656)[DEBUG] Closed socket >
Aug 22 22:21:09 123 systemd[1]: xrdp.service: Can't open PID file /run/xrdp/xrd>
Aug 22 22:21:10 123 systemd[1]: Started xrdp daemon.
Aug 22 22:21:11 123 xrdp[32550]: (32550)(140015163086656)[INFO ] starting xrdp >
Aug 22 22:21:11 123 xrdp[32550]: (32550)(140015163086656)[INFO ] address [0.0.0>
Aug 22 22:21:11 123 xrdp[32550]: (32550)(140015163086656)[INFO ] listening to p>
Aug 22 22:21:11 123 xrdp[32550]: (32550)(140015163086656)[INFO ] xrdp_listen_pp>
lines 1-21/21 (END)

Step 6:

iptables -I INPUT -p tcp --dport 3389 -j ACCEPT

or with ufw

sudo ufw allow 3389

Step 7: connect RDP by mstsc

mstsc xvnc

Leave a Reply