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:
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:
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
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"]
Reboot your system, you should be able connect to your target system via RDP, with clipboard, audio and improved performance.
- Kevin Cave’s X11RDP-o-Matic: https://github.com/scarygliders/X11RDP-o-Matic