The script hereafter is outdated and has been replaced by a newer version. Please Check the Download page for latest version.
|
Hello World,
Based on users feedback, comments and suggestions, we are releasing a new version of the famous xrdp-installer script. This new release basically fix some minor bugs that are addressed in this version and provide some better code logic. We had no time to perform really extensive testing but we hope that these small changes will not break the script.
The new version of our famous xrdp installation script will be set to 1.2.2 (i.e. xrdp-installer-1.2.2.sh). This script replaces all previous versions.
So, let’s go !
Overview
The xrdp-installer-1.2.2.sh script ease the installation and post-configuration actions of xRDP on top of Ubuntu Operating System. This version is the latest iteration of the script which include support for Ubuntu 20.10 (recently released in October 2020).
Script version & Supported Ubuntu Version
The script version will be set to 1.2.2. The xrdp-installer-1.2.2.sh script will support the following Ubuntu operating system version
- Ubuntu 16.04.x
- Ubuntu 18.04.x
- Ubuntu 20.04.x
- Ubuntu 20.10
Prerequisites and assumptions
The following conditions should be met in order to have the best results while using the script
- We assume that your machine is connected to internet while performing the installation. This is needed as additional packages and software needs to be downloaded and installed on your Ubuntu machine
- The script runs against a supported Operating system (Ubuntu 16.04.x, Ubuntu 18.04.x, Ubuntu 20.04, Ubuntu 20.10)
- The Official Ubuntu distribution needs to be used (we do not support other Ubuntu flavors so far !! – this might change in the future )
- No additional Desktop interface is used ( xRDP session will be showing Ubuntu Gnome Desktop with the Dock menu or Unity if running Ubuntu 16.04)
- Sound functionality is present on the computers if you sound feature is available as well
What’s new in this release ?
As mentioned above, the script has not changed much and only a few minor changes have been introduced. It consist mainly of esthetic changes and minor bug fixes as well as including users feedback suggestions into the script. So, the version 1.2.2 is addressing the following issues
- pointing to generic the ubuntu archive (archive.ubuntu.com) instead of using the localized one (be.archive.ubuntu.com) – Thanks to Thomas
- obtain automatically xrdp and xorgxrdp package from github and use this information to build packages when custom installation mode is used (Thanks to Hiero)
- force deletion of xrdp-installer-check.log file when remove option is selected to ensure that the xrdp folder is deleted accordingly (Thanks to Hiero)
- automating script versioning
A downloadable version of the script is available at the bottom of the post
How to Use the Script
The xrdp-installer-1.2.2 script will work in a similar way as the previous versions. The following section will explain how to download, extract, set executable mode and perform the installation using the script. The script provides some switches that can be used to customize the installation process.
So, let’s see how this would be working….
Disclaimer
Step 1 – Download the script
To download the script, you have multiple options. You can from a Terminal issue the following command
wget https://www.c-nergy.be/downloads/xrdp-installer-1.2.2.zip
You can also simply use your browser and click on the link to download the script :
Step 2 – unzip the file
After downloading the zip package containing the file, you will need to unzip it first. To unzip the package, you can use the Terminal console and issue the following command
unzip xrdp-installer-1.2.2.zip
You can also use the GUI and the Nautilus file manager to select the downloaded package, right-click on it and select the option Extract Here
Step 2 – Set Execute Right on the script
Download the xrdp-installer-1.2.2.sh script to your system, extract content and mark it as executable . To do this, perform the following action in a terminal console
chmod +x ~/Downloads/xrdp-installer-1.2.2.sh
Note : Adjust the path where the xrdp-Installer-1.2.2.sh script to reflect your environment
Step 2 – Run as normal user
The script needs to be run as a normal user. The script will start running and will prompt you for password when sudo actions are initiated. If you run the script as root or using sudo command, the Download folder does not exist for the root user and the script fails to run as expected. To overcome this situation, the script also check which user is executing the script. If the script is run under sudo or root accounts, a warning message will be displayed and the script will not execute
Step 3 – Switches and parameters
The xrdp-installer-1.2.2.sh script can be executed as is (with no parameters or switches). This will perform a standard (and basic) installation of xRDP. No sound or custom xrdp login script will be made available. However, remote desktop, drive redirection and clipboard redirection would be available with this installation mode.
The xrdp-installer-1.2.2.sh script accept also some additional parameters that will help customize the xrdp installation and enable additional features. The script provides the following parameters
--help or -h => will display a basic help menu --sound or -s => will enable sound redirection --loginscreen or -l => will customize the xRDP login screen --remove or -r => will remove the xrdp package --custom or -c => will perform a custom installation (i.e. compiled from sources)
Step 4 – Perform xRDP installation using the script
The following sections will provide some examples and scenario on how you can use the script…..
Standard Installation – No Parameter
As mentioned above, you can decide to use the default xrdp package available in the Ubuntu repository and perform a basic installation which will provide you remote desktop capability and will also customize the remote sesssion. The script will ensure that the same look n’ feel will be maintained when the user logs on locally or remotely.
To perform a standard installation, you execute the script with no parameters. Open a Terminal console, browse to the location where the script has been downloaded and issue the following command
./xrdp-installer-1.2.2.sh
When the xrdp installation package will start, you be requested to enter your password. Provide the password and proceed with the installation. Wait for completion of the script. The machine will not reboot automatically when done so you can review the actions performed by the script….
Important Notes
If you are running the script on Ubuntu 16.04.x, the custom installation will always be performed even if you have not specified any parameters. This is because Ubuntu 16.04.x ships with a really old xrdp package (version 0.6) and does not provides all needed features. The custom installation provide drive redirection, clipboard and access to Unity Desktop
Standard Installation with Parameters
The script can be used to perform a standard installation and still passes some parameters to get the most of the xRDP packages and their features. For all the Ubuntu versions, we could use the following combination of parameters
./xrdp-installer-1.2.2.sh -s (this would enable the sound redirection) ./xrdp-installer-1.2.2.sh -l (this would customize the xrdp login screen -see here)
Obviously, you can combine the switches (any order) to have more features enabled
./xrdp-installer-1.2.2.sh -s -l (this would enable the sound redirection and customize the xrdp login screen)
Important Notes
The script can be run multiple times on the same machine. If you have run initially the script with no parameters but you decide afterward to enable additional features, the script can be re-executed and the additional features will be enabled.
Custom Installation – Default Installation
Custom installation script is really flexible. Custom installation means that the script will compile the xrdp package from the source binaries. The custom installation script always uses the latest xrdp package version available
To perform a custom installation, you will need at minimum to pass one parameter. The following command line shows you how to perform a custom installation
./xrdp-installer-1.2.2.sh -c (this would perform a custom installation but will not enabled adv features like sound redirection or custom login screen)
Important Notes
If you are running the script on Ubuntu 16.04.x, the -c switch will be ignored and a custom installation process will be performed. This is because Ubuntu 16.04.x ships with a really old xrdp package (version 0.6) and does not provides all needed features. The custom installation provide drive redirection,clipboard and access to Unity Desktop
Custom Installation – Additional Options
If a user wants to enable additional features, you will pass some additional parameters as shown in the following examples
./xrdp-installer-1.2.2.sh -c -s (this would perform a custom install and enable sound redirection) ./xrdp-installer-1.2.2.sh -c -l (this would perform a custom install and customize xrdp login screen) ./xrdp-installer-1.2.2.sh -c -l -s (this would perform a custom install, enable sound and customize login screen)
Important Notes
The script can be run multiple times on the same machine. If you have run initially the script with no parameters but you decide afterward to enable additional features, the script can be re-executed and the additional features will be enabled.
Remove Installation option
This version of the script also ship with the option to remove xRDP package. The removal option should be only used if you have uses this version of this script to perform the installation. To remove the xrdp package, you would simply execute the following command
./xrdp-installer-1.2.2.sh -r (to remove the xrdp packages)
Step 5 – Test your configuration
After the script has run and after the reboot/shutdown and start process, it’s time to test and see if you can indeed perform a smooth remote connection to your Ubuntu machine. Remember that a user can either be logged on locally or logged on remotely on the machine when working with xRDP solution. If the user, performing the remote connection, is logged into the system locally the remote connection will start but will be terminated immediately. This is the way it works nowadays.
So, ensure that the user performing the test is not locally logged on, start your favorite remote desktop client and perform your connection. Based on your options, you will be presented either with the green xrdp login screen or with the custom login screen (purple background). Simply enter your credentials and start testing your installation. If everything is ok, you will see a similar Desktop interface where Gnome Desktop is used and the Dock is visible.
Known issues and limitations
Known Issues
Sound redirection Issue
If the Sound redirection option has been selected, rebooting the Ubuntu system is not enough and the sound redirection might not work. if the sound redirection option has been selected, you will have to shutdown your Ubuntu machine and then start it again in order to ensure that the sound redirection feature would work as expected.
Sound redirection is not working as expected on Ubuntu 19.10 and later The modules are created and copied to the correct location. However, the xrdp sink modules are never loaded in the remote session or randomly loaded in the remote session. To fix this, you simply need to execute the following command within your remote session and the sound will start working
pulseaudio -k
For detailed information, see post below
Drive Redirection
To redirect your drives to your xrdp remote session, you have to ensure that the only option selected in the local resources tab are the Clipboard option and the drive option. Check the screenshot below and ensure that you have the same settings.
Click on picture for better resolution
Click on picture for better resolution
When these settings have been set accordingly, you should see the thin client folder populated with redirected drives coming from your Windows machine.
Limitations
One session per user limitation
Only one session is allowed per user. This means that if a user is logged on locally on the Ubuntu machine, the user will not be able to perform a remote session (the xRDP connection will initiate but will end up immediately). If a user is logged on remotely on the system, it will not be able to login locally (if the user tries to login locally, the login screen will loop and the login screen will be presented again to the user)
Switch between standard and Custom install
This version of the script can be run multiple times on the same machine. However, because of this new behavior, you cannot perform a standard installation and then decide to perform the custom installation. Once you have selected your installation mode, you will have to stick to it. This is kind of checked by the script.
So, if you have performed a standard installation but afterwards you might want to use the custom installation option, the script will ignore the request. If you want to move from standard install mode to custom mode (or vice versa), the correct process is
- remove xrdp (using the xrdp-installer-1.2.2.sh -r option)
- perform a new installation using your selected installation mode (standard or custom install mode)
Download the Script
The script can be download at this location : xrdp-installer-1.2.2.zip
Note : All the xrdp scripts can be found at https://www.c-nergy.be/products.html
Final Notes
This is it for this post !
Please if you have time or want to help us in creating the best xrdp installer script, download the script, test it and provide constructive feedback. If you find a bug or an issue with the script, let us know as well so we can try to fix it.
Till next time
Annex – The Script Source code
#!/bin/bash ##################################################################################################### # Script_Name : xrdp-installer-1.2.2.sh # Description : Perform xRDP installation on Ubuntu 16.04,18.04,20.4,20.10 and perform # additional post configuration to improve end user experience # Date : December 2020 # written by : Griffon # WebSite :http://www.c-nergy.be - http://www.c-nergy.be/blog # Version : 1.2.2 # History : 1.2.2 - Changing Ubuntu repository from be.archive.ubuntu.com to archive.ubuntu.com # - Bug Fixing - /etc/xrdp/xrdp-installer-check.log not deleted when remove option # selected in the script - Force Deletion (Thanks to Hiero for this input) # - Bug Fixing - Grab automatically xrdp/xorgxrdp package version to avoid # issues when upgrade operation performed (Thanks to Hiero for this input) # : 1.2.1 - Adding Support to Ubuntu 20.10 + Removed support for Ubuntu 19.10 # 1.2 - Adding Support to Ubuntu 20.04 + Removed support for Ubuntu 19.04 # - Stricter Check for HWE Package (thanks to Andrej Gantvorg) # - Changed code in checking where to copy image for login screen customization # - Fixed Bug checking SSL group membership # - Updating background color xrdp login screen # - Updating pkgversion to x.13 for checkinstall process # : 1.1 - Tackling multiple run of the script # - Improved checkinstall method/check ssl group memberhsip # - Replaced ~/Downloads by a variable # : 1.0 - Added remove option + Final optimization # : 0.9 - updated compile section to use checkinstall # : 0.8 - Updated the fix_theme function to add support for Ubuntu 16.04 # : 0.7 - Updated prereqs function to add support for Ubuntu 16.04 # : 0.6 - Adding logic to detect Ubuntu version for U16.04 # : 0.5 - Adding env variable Fix # : 0.4 - Adding SSL Fix # : 0.3 - Adding custom login screen option # : 0.2 - Adding new code for passing parameters # : 0.1 - Initial Script (merging custom & Std) # Disclaimer : Script provided AS IS. Use it at your own risk.... # You can use this script and distribute it as long as credits are kept # in place and unchanged #################################################################################################### #--------------------------------------------------------------------------# # -----------------------Function Section - DO NOT MODIFY -----------------# #--------------------------------------------------------------------------# ############################################################################ # DEFAULT INSTALLATION MODE : STANDARD INSTALLATION ############################################################################ #---------------------------------------------------# # Function 1 - check xserver-xorg-core package.... #---------------------------------------------------# check_hwe() { Release=$(lsb_release -sr) echo /bin/echo -e "\e[1;33m |-| Detecting xserver-xorg-core package installed \e[0m" xorg_no_hwe_install_status=$(dpkg-query -W -f ='${Status}\n' xserver-xorg-core 2>/dev/null) xorg_hwe_install_status=$(dpkg-query -W -f ='${Status}\n' xserver-xorg-core-hwe-$Release 2>/dev/null) if [[ "$xorg_hwe_install_status" =~ \ installed$ ]] then # – hwe version is installed on the system /bin/echo -e "\e[1;32m |-| xorg package version: xserver-xorg-core-hwe \e[0m" HWE="yes" elif [[ "$xorg_no_hwe_install_status" =~ \ installed$ ]] then /bin/echo -e "\e[1;32m |-| xorg package version: xserver-xorg-core \e[0m" HWE="no" else /bin/echo -e "\e[1;31m |-| Error checking xserver-xorg-core flavour \e[0m" exit 1 fi } #---------------------------------------------------# # Function 2 - Install xRDP Software.... #---------------------------------------------------# install_xrdp() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Installing XRDP Packages...Proceeding... !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo if [[ $HWE = "yes" ]] && [[ "$version" = *"Ubuntu 18.04"* ]]; then sudo apt-get install xrdp -y sudo apt-get install xorgxrdp-hwe-18.04 else sudo apt-get install xrdp -y fi } ############################################################################ # ADVANCED INSTALLATION MODE : CUSTOM INSTALLATION ############################################################################ #---------------------------------------------------# # Function 0 - Install Prereqs... #---------------------------------------------------# install_prereqs() { echo Release=$(lsb_release -sr) /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Installing PreReqs packages..Proceeding. ! \e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo sudo apt-get -y install libx11-dev libxfixes-dev libssl-dev libpam0g-dev libtool libjpeg-dev flex bison gettext autoconf libxml-parser-perl libfuse-dev xsltproc libxrandr-dev python-libxml2 nasm fuse pkg-config git intltool checkinstall echo if [ $HWE = "yes" ]; then # - xorg-hwe-* to be installed /bin/echo -e "\e[1;32m |-| xorg package version: xserver-xorg-core-hwe-$Release \e[0m" sudo apt-get install -y xserver-xorg-dev-hwe-$Release xserver-xorg-core-hwe-$Release else #-no-hwe /bin/echo -e "\e[1;32m |-| xorg package version: xserver-xorg-core \e[0m" echo sudo apt-get install -y xserver-xorg-dev xserver-xorg-core fi } #---------------------------------------------------# # Function 1 - Download XRDP Binaries... #---------------------------------------------------# get_binaries() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Download xRDP Binaries.......Proceeding. ! \e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo #cd ~/Downloads Dwnload=$(xdg-user-dir DOWNLOAD) cd $Dwnload ## -- Download the xrdp latest files echo /bin/echo -e "\e[1;32m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;32m ! Preparing download xrdp package !\e[0m" /bin/echo -e "\e[1;32m !---------------------------------------------!\e[0m" echo git clone https://github.com/neutrinolabs/xrdp.git echo /bin/echo -e "\e[1;32m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;32m ! Preparing download xorgxrdp package !\e[0m" /bin/echo -e "\e[1;32m !---------------------------------------------!\e[0m" echo git clone https://github.com/neutrinolabs/xorgxrdp.git } #---------------------------------------------------# # Function 2 - compiling xrdp... #---------------------------------------------------# compile_source() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Compile xRDP packages .......Proceeding. !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo #cd ~/Downloads/xrdp cd $Dwnload/xrdp #Get the release version automatically pkgver=$(git describe --abbrev=0 --tags | cut -dv -f2) sudo ./bootstrap sudo ./configure --enable-fuse --enable-jpeg --enable-rfxcodec sudo make #-- check if no error during compilation if [ $? -eq 0 ] then /bin/echo -e "\e[1;33m |-| Make Operation Completed successfully \e[0m" else echo echo /bin/echo -e "\e[1;31m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;31m ! Error while Executing make !\e[0m" /bin/echo -e "\e[1;31m ! The Script is exiting.... !\e[0m" /bin/echo -e "\e[1;31m !---------------------------------------------!\e[0m" exit fi sudo checkinstall --pkgname=xrdp --pkgversion=$pkgver --pkgrelease=1 --default #xorgxrdp package compilation echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Compile xorgxrdp packages....Proceeding. !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo #cd ~/Downloads/xorgxrdp cd $Dwnload/xorgxrdp #Get the release version automatically pkgver=$(git describe --abbrev=0 --tags | cut -dv -f2) sudo ./bootstrap sudo ./configure sudo make # check if no error during compilation if [ $? -eq 0 ] then echo /bin/echo -e "\e[1;33m |-| Make Operation Completed successfully \e[0m" echo else echo /bin/echo -e "\e[1;31m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;31m ! Error while Executing make !\e[0m" /bin/echo -e "\e[1;31m ! The Script is exiting.... !\e[0m" /bin/echo -e "\e[1;31m !---------------------------------------------!\e[0m" exit fi sudo checkinstall --pkgname=xorgxrdp --pkgversion=1:$pkgver --pkgrelease=1 --default } #---------------------------------------------------# # Function 3 - create services .... #---------------------------------------------------# enable_service() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Creating xRDP services.......Proceeding. !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo sudo systemctl daemon-reload sudo systemctl enable xrdp.service sudo systemctl enable xrdp-sesman.service sudo systemctl start xrdp } ############################################################################ # COMMON FUNCTIONS - WHATEVER INSTALLATION MODE ############################################################################ #---------------------------------------------------# # Function 0 - Install Gnome Tweak Tool.... #---------------------------------------------------# install_tweak() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Installing Gnome Tweak...Proceeding... !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo sudo apt-get install gnome-tweak-tool -y } #--------------------------------------------------------------------# # Fucntion 1 - Allow console Access ....(seems optional in u18.04) #--------------------------------------------------------------------# allow_console() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Granting Console Access...Proceeding... !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config } #---------------------------------------------------# # Function 2 - create policies exceptions .... #---------------------------------------------------# create_polkit() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Creating Polkit File...Proceeding... !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo #All Ubuntu version sudo bash -c "cat >/etc/polkit-1/localauthority/50-local.d/45-allow.colord.pkla" <<EOF [Allow Colord all Users] Identity=unix-user:* Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile ResultAny=no ResultInactive=no ResultActive=yes EOF #Specific Versions if [[ "$version" = *"Ubuntu 20.10"* ]] || [[ "$version" = *"Ubuntu 20.04"* ]] ; then sudo bash -c "cat >/etc/polkit-1/localauthority/50-local.d/46-allow-update-repo.pkla" <<EOF [Allow Package Management all Users] Identity=unix-user:* Action=org.freedesktop.packagekit.system-sources-refresh ResultAny=yes ResultInactive=yes ResultActive=yes EOF fi } #---------------------------------------------------# # Function 3 - Fixing Theme and Extensions .... #---------------------------------------------------# fix_theme() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Fix Theme and extensions...Proceeding... !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" # Checking if script has run already if [ -f /etc/xrdp/startwm.sh.griffon ] then sudo rm /etc/xrdp/startwm.sh sudo mv /etc/xrdp/startwm.sh.griffon /etc/xrdp/startwm.sh fi #Backup the file before modifying it sudo cp /etc/xrdp/startwm.sh /etc/xrdp/startwm.sh.griffon if [[ "$version" = *"Ubuntu 16.04"* ]]; then echo sudo sed -i "/# auth /a cat >~/.xsession << EOF\n#Unity Xrdp multi-users \n/usr/lib/gnome-session/gnome-session-binary --session=ubuntu &\n/usr/lib/x86_64-linux-gnu/unity/unity-panel-service &\n/usr/lib/unity-settings-daemon/unity-settings-daemon &\nfor indicator in /usr/lib/x86_64-linux-gnu/indicator-*;\ndo\nbasename='basename \\\\\${indicator}'\ndirname='dirname \\\\\${indicator}'\nservice=\\\\\${dirname}/\\\\\${basename}/\\\\\${basename}-service\n\\\\\${service} &\ndone\nunity\nEOF" /etc/xrdp/startwm.sh echo else echo sudo sed -i "4 a #Improved Look n Feel Method\ncat <<EOF > ~/.xsessionrc\nexport GNOME_SHELL_SESSION_MODE=ubuntu\nexport XDG_CURRENT_DESKTOP=ubuntu:GNOME\nexport XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg\nEOF\n" /etc/xrdp/startwm.sh echo fi } #---------------------------------------------------# # Function 4 - Enable Sound Redirection .... #---------------------------------------------------# enable_sound() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Enabling Sound Redirection... !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo # Step 1 - Enable Source Code Repository sudo apt-add-repository -s 'deb http://archive.ubuntu.com/ubuntu/ '$codename' main restricted' sudo apt-add-repository -s 'deb http://archive.ubuntu.com/ubuntu/ '$codename' restricted universe main multiverse' sudo apt-add-repository -s 'deb http://archive.ubuntu.com/ubuntu/ '$codename'-updates restricted universe main multiverse' sudo apt-add-repository -s 'deb http://archive.ubuntu.com/ubuntu/ '$codename'-backports main restricted universe multiverse' sudo apt-add-repository -s 'deb http://archive.ubuntu.com/ubuntu/ '$codename'-security main restricted universe main multiverse' sudo apt-get update # Step 2 - Install Some PreReqs sudo apt-get install git libpulse-dev autoconf m4 intltool build-essential dpkg-dev libtool libsndfile-dev libcap-dev -y libjson-c-dev sudo apt build-dep pulseaudio -y # Step 3 - Download pulseaudio source in /tmp directory - Do not forget to enable source repositories cd /tmp sudo apt source pulseaudio # Step 4 - Compile pulsever=$(pulseaudio --version | awk '{print $2}') cd /tmp/pulseaudio-$pulsever sudo ./configure # step 5 - Create xrdp sound modules sudo git clone https://github.com/neutrinolabs/pulseaudio-module-xrdp.git cd pulseaudio-module-xrdp sudo ./bootstrap sudo ./configure PULSE_DIR="/tmp/pulseaudio-$pulsever" sudo make #Step 6 copy files to correct location (as defined in /etc/xrdp/pulse/default.pa) cd /tmp/pulseaudio-$pulsever/pulseaudio-module-xrdp/src/.libs sudo install -t "/var/lib/xrdp-pulseaudio-installer" -D -m 644 *.so sudo install -t "/usr/lib/pulse-$pulsever/modules" -D -m 644 *.so echo } #---------------------------------------------------# # Function 5 - Custom xRDP Login Screen .... #---------------------------------------------------# custom_login() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Customizing xRDP login screen !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo Dwnload=$(xdg-user-dir DOWNLOAD) echo "go to Download folder" echo echo $Dwnload #cd ~/Downloads cd $Dwnload wget http://www.c-nergy.be/downloads/griffon_logo_xrdp.bmp #Check if script has run once... if [ -f /etc/xrdp/xrdp.ini.griffon ] then sudo rm /etc/xrdp/xrdp.ini sudo mv /etc/xrdp/xrdp.ini.griffon /etc/xrdp/xrdp.ini fi #Backup file sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.griffon #Check where to copy the logo file if [ -d "/usr/local/share/xrdp" ] then echo "Directory /path/to/dir exists." sudo cp griffon_logo_xrdp.bmp /usr/local/share/xrdp sudo sed -i 's/ls_logo_filename=/ls_logo_filename=\/usr\/local\/share\/xrdp\/griffon_logo_xrdp.bmp/g' /etc/xrdp/xrdp.ini else sudo cp griffon_logo_xrdp.bmp /usr/share/xrdp sudo sed -i 's/ls_logo_filename=/ls_logo_filename=\/usr\/share\/xrdp\/griffon_logo_xrdp.bmp/g' /etc/xrdp/xrdp.ini fi #4F194C sudo sed -i 's/blue=009cb5/blue=dedede/' /etc/xrdp/xrdp.ini sudo sed -i 's/#white=ffffff/white=dedede/' /etc/xrdp/xrdp.ini sudo sed -i 's/#ls_title=My Login Title/ls_title=Remote Desktop for Linux/' /etc/xrdp/xrdp.ini sudo sed -i 's/ls_top_window_bg_color=009cb5/ls_top_window_bg_color=4F194C/' /etc/xrdp/xrdp.ini sudo sed -i 's/ls_bg_color=dedede/ls_bg_color=ffffff/' /etc/xrdp/xrdp.ini sudo sed -i 's/ls_logo_x_pos=55/ls_logo_x_pos=0/' /etc/xrdp/xrdp.ini sudo sed -i 's/ls_logo_y_pos=50/ls_logo_y_pos=5/' /etc/xrdp/xrdp.ini } #---------------------------------------------------# # Function 6 - Fix SSL Minor Issue .... #---------------------------------------------------# fix_ssl() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Fixing SSL Cert Issue ... !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo if id -Gn xrdp | grep ssl-cert then /bin/echo -e "\e[1;32m !--xrdp already member ssl-cert...Skipping ---!\e[0m" else sudo adduser xrdp ssl-cert fi } #---------------------------------------------------# # Function 7 - Fixing env variables in XRDP .... #---------------------------------------------------# fix_env() { #Add this line to /etc/pam.d/xrdp-sesman if not present if grep -Fxq "session required pam_env.so readenv=1 user_readenv=0" /etc/pam.d/xrdp-sesman then echo "Env settings already set" else sudo sed -i '1 a session required pam_env.so readenv=1 user_readenv=0' /etc/pam.d/xrdp-sesman fi } #---------------------------------------------------# # Function 8 - Removing XRDP Packages .... #---------------------------------------------------# remove_xrdp() { echo /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" /bin/echo -e "\e[1;33m ! Removing xRDP Packages... !\e[0m" /bin/echo -e "\e[1;33m !---------------------------------------------!\e[0m" echo #remove the xrdplog file created by the script sudo rm /etc/xrdp/xrdp-installer-check.log #remove xrdp package sudo systemctl stop xrdp sudo systemctl disable xrdp sudo apt-get autoremove xrdp -y sudo apt-get purge xrdp -y #remove xorgxrdp sudo systemctl stop xorgxrdp sudo systemctl disable xorgxrdp sudo apt-get autoremove xorgxrdp -y sudo apt-get purge xorgxrdp -y } sh_credits() { echo /bin/echo -e "\e[1;36m !----------------------------------------------------------------!\e[0m" /bin/echo -e "\e[1;36m ! Installation Completed...Please test your xRDP configuration !\e[0m" /bin/echo -e "\e[1;36m ! If Sound option selected, shutdown your machine completely !\e[0m" /bin/echo -e "\e[1;36m ! start it again to have sound working as expected !\e[0m" /bin/echo -e "\e[1;36m ! !\e[0m" /bin/echo -e "\e[1;36m ! Credits : Written by Griffon - Dec. 2020 !\e[0m" /bin/echo -e "\e[1;36m ! www.c-nergy.be -xrdp-installer-v$ScriptVer.sh !\e[0m" /bin/echo -e "\e[1;36m ! ver $ScriptVer !\e[0m" /bin/echo -e "\e[1;36m !----------------------------------------------------------------!\e[0m" echo } #---------------------------------------------------# # SECTION FOR OPTIMIZING CODE USAGE... # #---------------------------------------------------# install_common() { allow_console create_polkit fix_theme fix_ssl fix_env } install_custom() { install_prereqs get_binaries compile_source enable_service } #--------------------------------------------------------------------------# # -----------------------END Function Section -----------------# #--------------------------------------------------------------------------# #--------------------------------------------------------------------------# #------------ MAIN SCRIPT SECTION -------------------# #--------------------------------------------------------------------------# #---------------------------------------------------# # Script Version information Displayed # #---------------------------------------------------# #--Automating Script versioning ScriptVer="1.2.2" echo /bin/echo -e "\e[1;36m !---------------------------------------------------------------!\e[0m" /bin/echo -e "\e[1;36m ! xrdp-installer-$ScriptVer Script !\e[0m" /bin/echo -e "\e[1;36m ! Support U16.04/18.04/19.10/20.04/20.10 !\e[0m" /bin/echo -e "\e[1;36m ! Written by Griffon - Nov 2020 - www.c-nergy.be !\e[0m" /bin/echo -e "\e[1;36m ! !\e[0m" /bin/echo -e "\e[1;36m ! For Help and Syntax, type ./xrdp-installer-$ScriptVer.sh -h !\e[0m" /bin/echo -e "\e[1;36m ! !\e[0m" /bin/echo -e "\e[1;36m !---------------------------------------------------------------!\e[0m" echo #----------------------------------------------------------# # Step 0 -Detecting if Parameters passed to script .... # #----------------------------------------------------------# for arg in "$@" do #Help Menu Requested if [ "$arg" == "--help" ] || [ "$arg" == "-h" ] then echo "Usage Syntax and Examples" echo echo " --custom or -c custom xRDP install (compilation from sources)" echo " --loginscreen or -l customize xRDP login screen" echo " --remove or -r removing xRDP packages" echo " --sound or -s enable sound redirection in xRDP" echo echo "example " echo echo " ./xrdp-installer-$ScriptVer.sh -c -s custom install with sound redirection" echo " ./xrdp-installer-$ScriptVer.sh -l standard install with custom login screen" echo " ./xrdp-installer-$ScriptVer.sh standard install no additional features" echo exit fi if [ "$arg" == "--sound" ] || [ "$arg" == "-s" ] then fixSound="yes" fi if [ "$arg" == "--loginscreen" ] || [ "$arg" == "-l" ] then fixlogin="yes" fi if [ "$arg" == "--custom" ] || [ "$arg" == "-c" ] then adv="yes" fi if [ "$arg" == "--remove" ] || [ "$arg" == "-r" ] then removal="yes" fi done #--------------------------------------------------------------------------------# #-- Step 0 - Check that the script is run as normal user and not as root.... #-------------------------------------------------------------------------------# if [[ $EUID -ne 0 ]]; then /bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m" /bin/echo -e "\e[1;36m ! Standard user detected....Proceeding.... !\e[0m" /bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m" else echo /bin/echo -e "\e[1;31m !-------------------------------------------------------------!\e[0m" /bin/echo -e "\e[1;31m ! Script launched with sudo command. Script will not run... !\e[0m" /bin/echo -e "\e[1;31m ! Run script a standard user account (no sudo). When needed !\e[0m" /bin/echo -e "\e[1;31m ! script will be prompted for password during execution !\e[0m" /bin/echo -e "\e[1;31m ! !\e[0m" /bin/echo -e "\e[1;31m ! Exiting Script - No Install Performed !!! !\e[0m" /bin/echo -e "\e[1;31m !-------------------------------------------------------------!\e[0m" echo #sh_credits exit fi #---------------------------------------------------# #-- Step 1 - Try to Detect Ubuntu Version.... #---------------------------------------------------# version=$(lsb_release -sd) codename=$(lsb_release -sc) echo /bin/echo -e "\e[1;33m |-| Detecting Ubuntu version \e[0m" if [[ "$version" = *"Ubuntu 16.04"* ]]; then /bin/echo -e "\e[1;32m |-| Ubuntu Version : $version\e[0m" echo elif [[ "$version" = *"Ubuntu 18.04"* ]]; then /bin/echo -e "\e[1;32m |-| Ubuntu Version : $version\e[0m" echo elif [[ "$version" = *"Ubuntu 20.04"* ]]; then /bin/echo -e "\e[1;32m |-| Ubuntu Version : $version\e[0m" echo elif [[ "$version" = *"Ubuntu 20.10"* ]]; then /bin/echo -e "\e[1;32m |-| Ubuntu Version : $version\e[0m" echo else /bin/echo -e "\e[1;31m !--------------------------------------------------------------!\e[0m" /bin/echo -e "\e[1;31m ! Your system is not running a supported version !\e[0m" /bin/echo -e "\e[1;31m ! The script has been tested only on the following versions !\e[0m" /bin/echo -e "\e[1;31m ! U16.04.x/18.04.x/19.10/20.0X !\e[0m" /bin/echo -e "\e[1;31m ! The script is exiting... !\e[0m" /bin/echo -e "\e[1;31m !--------------------------------------------------------------!\e[0m" echo exit fi #----------------------------------------------------------------------- #Step 2 - checking for additional Settings - xorg-xserver-core version #---------------------------------------------------------------------- check_hwe #--------------------------------------------------------------------------------# #-- Step 3 - Check if Removal Option Selected #--------------------------------------------------------------------------------# if [ "$removal" = "yes" ]; then remove_xrdp echo sh_credits exit fi #---------------------------------------------------------# # Step 4 - Executing the installation & config tasks .... # #---------------------------------------------------------# #------------------------------------------------------------------- #- If Ubuntu 16.04 detected, we always perform a custom installation #------------------------------------------------------------------- #Check if script has run once... if [ -f /etc/xrdp/xrdp-installer-check.log ] then echo /bin/echo -e "\e[1;36m !----------------------------------------------------------------!\e[0m" /bin/echo -e "\e[1;36m ! INFO : xrdp-install script ran at least once on this computer. !\e[0m" /bin/echo -e "\e[1;36m !----------------------------------------------------------------!\e[0m" else if [[ "$version" = *"Ubuntu 16.04"* ]]; then echo /bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m" /bin/echo -e "\e[1;36m ! Custom Installation for Ubuntu 16.04.x !\e[0m" /bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m" echo install_custom install_common fi #--------------------------------------------------------------------------------------- #- If custom option detected, additional check for U16.04 so skipped #---------------------------------------------------------------------------------------- if [[ "$version" != *"Ubuntu 16.04"* ]]; then if [ "$adv" = "yes" ]; then echo /bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m" /bin/echo -e "\e[1;36m ! Custom Installation Option Selected..... !\e[0m" /bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m" echo install_custom install_tweak install_common else echo /bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m" /bin/echo -e "\e[1;36m ! Standard Installation Mode Selected - U18.04 and later !\e[0m" /bin/echo -e "\e[1;36m !-------------------------------------------------------------!\e[0m" echo install_xrdp install_tweak install_common fi #end if Adv option fi # end if version check not like U16.04 fi # End check if file exists #--------------------------------------------------------------------------------------- #- Check for Additional Options selected #---------------------------------------------------------------------------------------- if [ "$fixSound" = "yes" ]; then enable_sound fi if [ "$fixlogin" = "yes" ]; then echo custom_login fi #----------------------------------------------------------------------- # Create Check file to see if script has run at least once... #---------------------------------------------------------------------- #Create the log file sudo touch /etc/xrdp/xrdp-installer-check.log #--------------------------------------------------------------------------------------- #- show Credits and finishing script #--------------------------------------------------------------------------------------- sh_credits
Hi, here is a fix for the sound rediraction :
sed -i “s/Exec=start-pulseaudio-x11/Exec=pulseaudio -k/” /etc/xdg/autostart/pulseaudio.desktop
@Sebastian,
Thank you for visiting our blog and providing feedback and sharing your findings…
We have been looking for solutions to automatically start the sound process. We have investigate multiple options.. We like your approach but we have noticed inconsistent results.
We will probably add your tip in the next iteration of the script
Thank you for the feedback
Till next time
See ya
@maxéveg,
Sorry for the delay in the feedback
Thank you for your feedback and for the information you are sharing…
for Ubuntu 20.10, you are telling me that you can have the same user logged on locally and remotely and have everything working as expected ?
Can you share your /etc/xrdp/startwm.sh content file to see if you have added some additional commands
are you sure you are using pure xRDP and not performing a vnc server connection ?
waiting for your feedback
Till next time
See ya
Hi, is there a way to disable reconnection?
I want to start a new session for every single incoming connection.
I’m on a 16.04 machine and I’ve seen a lot of questions asking for the exact opposite of what I want, but I can’t reproduce the behavior at all with tightvnc, even when using the packaged version of xrdb (which just doesn’t work).
Btw thank you so much for the script and blog, they’re great!
@Joao;
Thank for visiting our blog and sharing your experience…
Hmmmm, about your question…. You have mentioned that you are on Ubuntu 16.04… (which is end of standard support)
Secondly, which version of xRDP are you using (the default xrdp package from Ubuntu repository or you have performed a custom install and you are running xrdp vers 0.9.x)
If you have a recent version of xRDP and you are using xorgxrdp software as backend, you should be able to achieve what you are asking for by modifying values in /etc/xrdp/sesman.ini
So, please locate the following parameters and ensure that the following values are set accordingly
KillDisconnected=false
DisconnectedTimeLimit=0
Waiting for your feedback
Hope this help
Till next time
See ya
hi i ran the script as a normal user, it ask for the sudo password, but it dont take the password it says sorry, try again. while the same sudo password work fine when i run su on the same terminal, it is on ubuntu 20.04.
@Baradharajan,
Thank you for visiting our blog and sharing your experience…the problem is not with the script.. the problem is with the password you are using….su and sudo are different commands…
open a command prompt, and type sudo nano…you will be prompted for a password…. if this is not working, this is clearly a problem with the password you are trying to use…. you might need to use another one
Hope this help
till next time
See ya
Hi Griffon – sorry it took me a while (month) to respond:
> Thank you for your feedback and for the information you are sharing…
for Ubuntu 20.10, you are telling me that you can have the same user logged on locally and remotely and have everything working as expected ?
That is correct, I log in w/ my user, then use “Microsoft Remote Desktop” on my iPad / Mac / Windows to remote into GUI; works also if just remoting in via above app, staying logged in, then logging in locally – remote RDP stays logged in.
> Can you share your /etc/xrdp/startwm.sh content file to see if you have added some additional commands
Hopefully these will give you any clue as to how / why it works for me (system was originally 20.04, which I then dist-upgraded to 20.10):
My /etc/xrdp/startwm.sh
https://pastebin.com/7Jg5jhcJ
My /etc/xrdp/xrdp.ini
https://pastebin.com/1J0cgj5E
> are you sure you are using pure xRDP and not performing a vnc server connection ?
🤷🏻 I guess? lol… let me know if there’s a command you’d like me to run to test that – but considering that I’m using “Microsoft Remote Desktop”, I’d say so… I specify user and pass in the app, it just logs straight to the lock screen, I provide pass, I’m in; however, I noticed that sometimes the prompt keeps showing up, but that might be for updates, I don’t remember the exact scenarios.
> waiting for your feedback
> Till next time
> See ya
I hope this helped… I think there might be other files in play that have something to do with this, but not sure. Might also be that it’s an older version of xrdp that’s installed, allowing my scenario to work the way it does? Again, let me know of any commands for me to run or config files to post, and I will see what I can do.
Hi Griffon – sorry it took me a while (month) to respond:
> Thank you for your feedback and for the information you are sharing…
for Ubuntu 20.10, you are telling me that you can have the same user logged on locally and remotely and have everything working as expected ?
That is correct, I log in w/ my user, then use “Microsoft Remote Desktop” on my iPad / Mac / Windows to remote into GUI; works also if just remoting in via above app, staying logged in, then logging in locally – remote RDP stays logged in.
> Can you share your /etc/xrdp/startwm.sh content file to see if you have added some additional commands
Hopefully these will give you any clue as to how / why it works for me (system was originally 20.04, which I then dist-upgraded to 20.10):
My /etc/xrdp/startwm.sh
https://pastebin.com/7Jg5jhcJ
My /etc/xrdp/xrdp.ini
https://pastebin.com/1J0cgj5E
> are you sure you are using pure xRDP and not performing a vnc server connection ?
🤷🏻 I guess? lol… let me know if there’s a command you’d like me to run to test that – but considering that I’m using “Microsoft Remote Desktop”, I’d say so… I specify user and pass in the app, it just logs straight to the lock screen, I provide pass, I’m in; however, I noticed that sometimes the prompt keeps showing up, but that might be for updates, I don’t remember the exact scenarios.
> waiting for your feedback
> Till next time
> See ya
I hope this helped… I think there might be other files in play tahat have something to do with this, but not sure. Might also be that it’s an older version of xrdp that’s installed, allowing my scenario to work the way it does? Again, let me know of any commands for me to run or config files to post, and I will see what I can do.
Hello Max2veg,
thank you for coming back to us :). So based on your xrdp files, we can see that the /etc/startwm.sh has been modified which allows you to indeed have local and remote connection
We can see on line 12 and 13, the following code
unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR
which make the login locally and remotely concurrently working. We have explained and describe the issue and the workaround in the following post xRDP – Allow multiple sessions (local and remote) for the same user – HowTo.
Based on this information, we can confirm that you are using xrdp and using xorgxrdp as backend software and no vnc server is in used
To check the version of xrdp, you can simply type the following command in a Terminal Console
xrdp -v
Hope that this information is helpful to you
Again, thank you for coming back to us with the info
Till next time
See ya
Hi Griffon, I am attempting to get access to a Ubuntu 20.04 server. I have used the script with no errors reported. I am able to connect to the server via ssh. When I attempt to connect via rdesktop or Windows RDC I am presented with the normal xrdp connection window. Having entered the login details I am presented with a window which has a terminal in the top left corner (and the rest of the window is ‘blank’). The terminal is operational and the connection is ‘killed’ when I enter ‘exit’ at the terminal prompt.
The only real oddity with this installation is that I access the server via a VPN connection so I get through the remote site firewall via the VPN then make the connection from the remote site LAN using remote site private IP address.
I do have operational remote connection to other machines on the remote site but the others are Windows machines (still using rdesktop on my local machine).
Any suggestions as to a fix will be appreciated.
@Peter,
thank you for your visit and the feedback
Quick guess… have you installed any Desktop interface on your Ubuntu 20.04 server.. is the DE gnome or something else like xfce, kde,….. ?
the script works only on Ubuntu with Gnome Desktop interface… A new version of the script is being working out in order to add more Desktop Environment interface
Hope this help
Till next time
See ya
I ran the script on 20.04 Ubuntu and it doesn’t work. When I connect remotely, I get a black screen.
In an unrelated question, what happens if a user is using xfce and not the default?
Hello
I have installed your program on Ubuntu 18.04.2 TLS
But did not resolve the problem:
Conecting to sesman ip 127.0.0.1 port 3350
sesman connect ok
sending login info to session manager,please wait
login failed for display 0
Thanks do you have a tip?
@Maurice,
Thank you for visiting our blog and providing feedback… Usually, when you have the black screen symptom, it usually means that you are using the same user account to login locally and remotely at the same time….. To validate this…please reboot your Ubuntu machine (and do not login) and then try to perform the remote connection…This should be working…
about xfce question…. This version of the script has been tested normally on gnome Desktop only…..So, we would assume that if you have xfce desktop and you have run the script, conflict will occur
You will need to remove the code we have added in the /etc/xrdp/startwn.sh (should be located at the beginning of the file)
Hope this help
Till next time
See ya
@Jose and Phil,
Thank you for visiting our blog and providing some feedback…
Based on the symptoms, we would guess that xorgxrdp package is not installed correctly
Can you provide more info about your installation
How did you run the script (standard installation or custom installation ? Which switch have you used…)
xrdp version in use (type in command line xrdp -v)
xorgxrdp installed or not (type in a command line dpkg -l | grep xorgxrdp => which version installed
Can you run the following command sudo apt-get install xorgxrdp ? is it installing the package or stating that already installed
Try this and provide feedback if possible
Till next time
See ya
Thanks for the script. I am able to RDP from Windows
@Vinod,
Thank you for visiting our blog and providing feedback… Happy to see that the information we are providing has been helpful to you
till next time
See ya
Nice script. Works prefect.
I can remote my laptop and I can remote a Hyper-V version of Ubuntu 20.04.
Thanks.
@Nico,
Thank for visiting our blog and providing feedback… Always good to see that this blog can be helpful 🙂
Till next time
See ya
This was perfect!!!!! love open source community – thank you Griffon!!
@Ren,
Thank you for visiting our blog and providing positive feedback. Nice to see that the old version of the script still works but please be aware that a newer version of the script is available. always use the latest version of the script. You can find the latest version at http://www.c-nergy.be/products.html
Till next time
See ya