Categories
Linux

Getting x11rdp working on Debian 8, Jessie, with the help of X11RDP-o-Matic

Note: there is currently a bug that stops X11RDP installation on Debian 8.7: https://github.com/scarygliders/X11RDP-o-Matic/issues/81

I recently posted about using RDP to connect to Debian 8 clients via xrdp and, things were going well until I tried to redirect session sound and then started looking into the default xrdp configuration; it turns out that the default xrdp package leveraged vnc… yes, vnc. Surely there has to be a more effective way…?

This got my looking at x11rdp, which can provide native RDP connectivity with the following benefits:

  • Redirected sound
  • Redirected clipboard (copy paste between remote host and client)
  • Better visuals / performance (YMMV)
  • (to follow) use of Remote-FX for improved video playback etc.

I came across Kevin Cave’s X11RDP-o-Matic, however this did not support Debian 8, but it gave me 90% of what I needed.

After a while of trying to figure out what was causing the script to fail on Debian 8, I submitted a pull request to modify the “required packages” associated with the “–withjpeg” compile flag. Until this is committed, in some form, I have created a modified copy of the main script here.

All of the below is performed and tested on a vanilla Debian 8.6 machine , via a remote SSH console – your mileage may vary should your configuration not match.

Pre-flight checks / pre-requisites

You’ll need to ensure you’re running KDE or XFCE. This will not work with GNOME.

I’ve used sudo throughout this post, so install and add your non root user to the group (alternatively get all of my code snips and remove sudo!) – git is also used from the offset, so I have included this here.

apt-get install -y sudo git
adduser <user account> sudo

Log off and login again via SSH to refresh your groups, allowing sudo to work.

Now update your Debian install prior to continuing to build and install x11rdp.

apt-get update
apt-get dist-upgrade -y

Download and Execute X11RDP-o-Matic

# Download X11RDP-o-Matic 
git clone https://github.com/scarygliders/X11RDP-o-Matic
cd X11RDP-o-Matic

# Download modified X11rdp-o-matic.sh and chmod +x
wget https://www.dropbox.com/s/obrg90m4djhb2ct/DEV-X11rdp-o-matic.sh
chmod +x DEV-X11rdp-o-matic.sh

# Build and install x11rdp and xrdp packages - this will take a while!
sudo ./DEV-X11rdp-o-matic.sh --interactive --withjpeg --withsimplesound --withpulse --withkerberos --withpamuserpass --withfreerdp

Fix anomalous “.service” files 

Comment out “EnvironmentFile” line and changing the PIDFile location for:

  • /lib/systemd/system/xrdp.service
  • /lib/systemd/system/xrdp-sesman.service
sudo sed -i 's/EnvironmentFile/#EnvironmentFile/g' /lib/systemd/system/xrdp-sesman.service

sudo sed -i 's/PIDFile=\/var\/run\/xrdp.pid/PIDFile=\/run\/xrdp.pid/g' /lib/systemd/system/xrdp-sesman.service

sudo sed -i 's/EnvironmentFile/#EnvironmentFile/g' /lib/systemd/system/xrdp.service

sudo sed -i 's/PIDFile=\/var\/run\/xrdp-sesman.pid/PIDFile=\/run\/xrdp-sesman.pid/g' /lib/systemd/system/xrdp.service

Now, reload service definitions and enable / start services.

sudo systemctl daemon-reload
sudo systemctl enable xrdp-sesman
sudo systemctl enable xrdp
sudo systemctl start xrdp-sesman
sudo systemctl start xrdp

Generate xrdp rsakeys.ini

Now, generate xrdp rsakeys.ini, without this you’ll be unable to connect and get errors in event /var/log/xrdp-sesman.log  as below:

  • [ERROR] Listening socket is in wrong state we terminate listener
  • XRDP cannot read file: /etc/xrdp/rsakeys.ini (check permissions)
sudo xrdp-keygen xrdp auto 2048 

Build Debian 8 pulseaudio xrdp sink modules

You should download the version of pulseaudio nearest to that in your disto – check using:

pulseaudio --version

Now, download the pulseaudio source and configure – note you do not have to make / make install pulseaudio.

Be sure to change the version number (5.0, in bold, below) to match that from the command above.

sudo apt-get install -y libjson0-dev libsndfile1-dev libspeex-dev libspeexdsp-dev libcap-dev

cd /tmp
wget https://freedesktop.org/software/pulseaudio/releases/pulseaudio-5.0.tar.gz
tar -zxvf pulseaudio-5.0.tar.gz
cd /tmp/pulseaudio-5.0
./configure

Now, build the modules and copy them to /usr/lib/pulse-5.0/modules and, finally for the xrdp sink modules, call them to /etc/pulse/default.pa.

Again, watch the version numbers / paths as you may need to change these for your build.

cd ~/X11RDP-o-Matic/work/xrdp/sesman/chansrv/pulse/

# Change the patch here to match your path
sudo sed -i 's/PULSE_DIR = \/home\/lk\/pulseaudio-1.1/PULSE_DIR = \/tmp\/pulseaudio-5.0/g' Makefile

sudo make
sudo cp *.so /usr/lib/pulse-5.0/modules/

cd ~
sudo cp /etc/pulse/default.pa ~
sudo sed -i -e '$amodule-xrdp-sink.so' /etc/pulse/default.pa
sudo sed -i -e '$amodule-xrdp-source.so' /etc/pulse/default.pa

Build .xsession Files

We now need to call the RDPsesconfig.sh script contained within the X11RDP-o-Matic package. This will build the .xsession file for all users.

I’d stress that feedback (from comments below) and my own experience shows that Gnome will not work via x11rdp, or xrdp for that matter. KDE and XFCE both work.

cd ~/X11RDP-o-Matic/
sudo ./RDPsesconfig.sh

Optional Steps

Fix en-GB keyboard layout:

wget https://www.dropbox.com/s/rtxp19ts17k8qy8/km-0809.ini
cp km-0809.ini /etc/xrdp/

sed -i '/\[default_rdp_layouts\]/a rdp_layout_gb=0x00000809' /etc/xrdp/xrdp_keyboard.ini

sed -i '/\[default_layouts_map\]/a rdp_layout_gb=gb' /etc/xrdp/xrdp_keyboard.ini

Set background colour of logon prompt to be black, not very light/ luminescent blue:

sed -i 's/ls_top_window_bg_color=009cb5/ls_top_window_bg_color=000000/g' /etc/xrdp/xrdp.ini

You can also remove unnecessary session options from xrdp-sesman as outlined below.

sudo vi /etc/xrdp/xrdp.ini
# manually remove lines associated with [xrdp2] to just before ["Session manager"] ; be sure to leave any lines including/onwards from  ["Session manager"]

Finally

Reboot your system, you should be able connect to your target system via RDP, with clipboard, audio and improved performance.

References

 

 

15 replies on “Getting x11rdp working on Debian 8, Jessie, with the help of X11RDP-o-Matic”

Hi Chris,

I have tried to follow your guide on a fresh debian 8.6 install in a Hyper-V based VM and ran into a few problems. After a few hours of debugging I got XRDP working without the sound, which is a big win for me.
I hope I can help others who run into these types of issues.

First note, don’t use GNOME. it took me some searching to understand GNOME does not work nicely with XRDP. In my opinion this is due to incorrect handling of of the failing display-size reporting from xrandr, but I have not further investigated. When I configured the box with GNOME it first worked ok from the console, but after a reboot it started failing completely. I now use KDE and it works much better.

Second, in your rsa-key setup it says to use:
RSAKEYS=/etc/xrdp/rsakeys.ini
sudo xrdp-keygen xrdp /etc/xrdp/rsakeys.ini auto

this doesn’t work (and me not looking at the output didn’t help in finding this the first time).

you can either use:
sudo xrdp-keygen xrdp /etc/xrdp/rsakeys.ini
or
sudo xrdp-keygen xrdp auto

last, it’s a good idea to set the requested resolution in the RDP client, I am running a 2560×1440 session from a macbook pro and it’s stunning.

I want to thank you for your great write-up. It was by far the best guide so far for a workable linux GUI virtual desktop deployment.

best regards,

Erwin

Erwin, thanks for this – I have updated the xrdp-keygen command as I have also learnt by default this only uses a 512bit key, so adjusted the command to use 2048. I have also reflected your comments around GNOME, I myself tried this and got a swathe of error messages, wheres KDE or XFCE work just fine.

Did you follow the pulseaudio steps to get sound working?

Worth taking a look at the guacamole posts I’ve recently done, makes managing yur connections really simple 🙂

Erwin, thanks for this – I have updated the xrdp-keygen command as I
have also learnt by default this only uses a 512 bit key, so adjusted the
command to use 2048 bit. I have also reflected your comments around GNOME, I
myself tried this and got a swathe of error messages, wheres KDE or
XFCE work just fine.

Did you follow the pulseaudio steps to get sound working?

Worth taking a look at the guacamole posts I’ve recently done, makes managing yur connections really simple

Hi Chris,

Just did the audio part. All working now.
I noticed you mentioned the text in bold, which is not very clear in my browser. you might want to change it to something like: modify the 5.0 version to the appropriate version for you installation. In debian 8.6 this is pulse audio 5.0, so the title of the document kinda gives it away 😉

second thing tiny bit:

“sudo sed -i ‘s/PULSE_DIR = /home/lk/pulseaudio-1.1/PULSE_DIR = /home/chris/Downloads/pulseaudio-5.0/g’ Makefile”

the 2nd path refers to your home directory (which happens to be different from mine). you might want to change the sed statement or mention something about it in the comments.

I can’t get it to work in Konqueror yet, but it plays the test-sounds, so technically it works :).

Erwin

I’ve switched the path to /tmp – thought I had removed all of these!

I’ve also tried to better reflect the need to change the version number.

Thanks for your feedback 🙂

Installed just for tests and works great. However I don’t need it – how to uninstall it? Please help. Thank you.

Tried it on a fresh build of Debian 8.7
failed on building X11RDP
make[1]: Leaving directory ‘/home/localuser/X11RDP-o-Matic/work/xrdp-0.9.1 x
x dh_installdocs x
x cp: cannot stat ‘prog_std.txt’: No such file or directory x
x dh_installdocs: cp -a prog_std.txt debian/xrdp/usr/share/doc/xrdp returned x
x debian/rules:22: recipe for target ‘binary’ failed x
x make: *** [binary] Error 2 x
x dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit sta x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
mv: cannot stat ‘xrdp*.deb’: No such file or directory

Hi!

I am trying to setup xrdp on Debian 8 with your hints, but there seem to have changed some things:

As https://raw.github.com/neutrinolabs/xrdp/$XRDPBRANCH/readme.txt does not exist anymore, the script terminates. I removed it and changed VERSION=0.9.1+master

Second problem is, that the script terminates on compiling – I think, the patch-file does not fit anymore. If I try to compile without using all the core, the script terminates immediately. If I chose to user all the cores, I get:
patching file buildx.sh
Hunk #1 FAILED at 250.
1 out of 1 hunk FAILED — saving rejects to file buildx.sh.rej

Can you give me a hint on how to proceed?

Regards,
TC

Leave a Reply

Your email address will not be published. Required fields are marked *