Skip to content

Instantly share code, notes, and snippets.

@djravine
Last active July 25, 2024 01:03
Show Gist options
  • Save djravine/88f2b9957a0bef6a6dd4c55aca951a09 to your computer and use it in GitHub Desktop.
Save djravine/88f2b9957a0bef6a6dd4c55aca951a09 to your computer and use it in GitHub Desktop.
Setup Local xRDP on Ubuntu 18.04
#!/bin/bash
set -xuo pipefail
# GIST: https://gist.github.com/djravine/88f2b9957a0bef6a6dd4c55aca951a09
# USAGE: curl -sL https://gist.github.com/djravine/88f2b9957a0bef6a6dd4c55aca951a09/raw | bash -s --
# INSTALL SOFTWARE
sudo apt-get update
sudo apt-get install -y \
ubuntu-desktop \
xorg \
xrdp \
xorgxrdp \
xorg-video-abi-23 \
xserver-xorg-core \
xserver-xorg-input-all \
xfonts-base \
xfonts-75dpi \
xfonts-100dpi \
mate-core \
mate-desktop-environment \
mate-notification-daemon \
indicator-sound-gtk2 \
indicator-application-gtk2 \
ubuntu-gnome-desktop \
gnome-session-flashback \
gnome-panel \
gnome-tweak-tool \
xfce4 \
xfce4-goodies
sudo apt-get autoremove -y
# AUTH POPUP
sudo bash -c 'cat > /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf' << EOF
polkit.addRule(function(action, subject) {
if ((action.id == "org.freedesktop.color-manager.create-device" ||
action.id == "org.freedesktop.color-manager.create-profile" ||
action.id == "org.freedesktop.color-manager.delete-device" ||
action.id == "org.freedesktop.color-manager.delete-profile" ||
action.id == "org.freedesktop.color-manager.modify-device" ||
action.id == "org.freedesktop.color-manager.modify-profile") &&
subject.isInGroup("{users}")) {
return polkit.Result.YES;
}
});
EOF
# ALLOW FIREWALL
sudo ufw allow 3389/tcp
# SET SESSION MANGER
if [ -f /home/${USER}/.xsession ]; then
rm -f /home/${USER}/.xsession
fi
cat << 'EOF' >> /home/${USER}/.xsession
export LOGNAME=$USER
export LIBGL_ALWAYS_INDIRECT=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
mate-session # Works
#gnome-session --session=gnome-flashback-metacity --disable-acceleration-check & gnome-panel # Works
#xfce4-session # Works
EOF
chmod +x /home/${USER}/.xsession
# RUN BASH NOT SH
sudo sed -i "s|#\!/bin/sh|#\!/bin/bash|g" /etc/X11/Xsession
# ADD XRDP USER TO SSL-CERT GROUP
sudo adduser xrdp ssl-cert
# XRDP - RESTART
sudo service xrdp restart
# XRDP - STATUS
sudo service xrdp status
@ironbila
Copy link

Very nice out of the box working setup. +1

@tadam98
Copy link

tadam98 commented Jan 14, 2021

Works very nice. I have a strange problem. I am connected to my workstation with VNC. Additionally, I connected with RDP session. When I start Nautilus on the main desktop, it opens on the RDP desktop. If I disconnect it - it keeps looking for the remote desktop.

Also, when xrp is installed, my terminal will not open. So I had to remove evenryting.

I am not sure how to stop the remote session.

@szapp
Copy link

szapp commented Nov 14, 2022

Is there an exact reversal procedure to the listed steps of the script, specifically for removing the added rules?

@djravine
Copy link
Author

Is there an exact reversal procedure to the listed steps of the script, specifically for removing the added rules?

You could move the conf file that was created into a backup file so it doesn't get run
mv /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf.backup

@creativ-ii
Copy link

worked perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment