How to install xrdp on Ubuntu 18.04 + Customization
This tutorial will guide to install xrdp with either XFCE or MATE interface with customizations to increase productivity. Installation of xrdp on ubunut 18.04 with customization.
What is xRdp?
It’s a free and open source app which provides a graphical login to your server to control it as if you are controlling your own desktop. It uses rdp (Microsoft Remote Desktop Protocol) to let it connect to your desktop with the help of any rdp client like Microsoft Desktop Connection
Requirements
# A freshly installed server with ubuntu 18.04 (Bionic) [Ofcourse you can use this tutorial to install it on ubuntu 20.04]
# A root user
# All other requirements will be stated in between the steps as per the necessity
If you don’t have a VPS then you can try Hostlease: HOSTLEASE
Installation
Step 1: Log in to the server with sudo privelege
Log in on a Mac or Linux
ssh username@IPaddress_of_your_server
Log in on Windows
Use Putty to fire up your ssh session!
Latest release can be found here: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Step 2: Updating
Before heading to xrdp installation packages we have to update the system package lists! It will also add new packages to the repository if any new packages for system are available.
sudo apt-get update
Step 3: Installing xrdp
After update, Install the latest xrdp packages with the following commands
sudo apt-get install xrdp
Step 4: Choosing the Preferred desktop environment
The most widely used Desktop environment for remote servers are XFCE and MATE.
Both have their pros and cons.
If you want to install xfce then type the command which is given in XFCE section or else for MATE type commands in MATE Section
XFCE
To install XFCE
sudo apt-get install xfce4
And to install XFCE terminal
sudo apt-get install xfce4-terminal
MATE
To install MATE
sudo apt-get install mate-core mate-desktop-environment mate-notification-daemon
Step 5: Now adding configurations to use your selected environment
If you choose xfce then configure accordingly to it
sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n xfce-session \n' /etc/xrdp/startwm.sh
If you choose MATE then configure accordingly to it
sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n mate-session \n' /etc/xrdp/startwm.sh
Step 6: Adding xrdp to “ssl-cert” group
By default Xrdp uses the /etc/ssl/private/ssl-cert-snakeoil.key file which is readable only by users that are members of the “ssl-cert” group. Execute the following command to add the xrdp user to the group
sudo adduser xrdp ssl-cert
Step 7: Allowing RDP port in Firewall
- ERROR: WHEN I WAS CONFIGURING UFW RULES I GOT ONE ERROR “sudo: ufw: command not found” . IT HAPPENED BECAUSE UFW WAS NOT INSTALLED ON UBUNTU 18.04
- FIX:
sudo apt-get install ufw
Then, add port 3389 to the firewall
sudo ufw allow 3389/tcp
OR
If you are using iptables on your ubuntu 18.04 server already then {don’t know what it is or don’t know whether you are using it or not then use ufw}
sudo iptables -A INPUT -p tcp --dport 3389 -j ACCEPT
sudo netfilter-persistent save
sudo netfilter-persistent reload
Step 8: Restart XRDP
sudo /etc/init.d/xrdp restart
Step 9: Adding a user other than root with sudo priveleges
First add a user
sudo adduser <username>EXAMPLE: sudo adduser aps
If there is already a user with the same username then you will get a error lik
useradd: user <username> already exists
Now Add that user to sudo group
sudo usermod -aG sudo <username>EXAMPLE: sudo usermod -aG sudo aps
Step 10: Opening the session
This is the most interesting part as you will be able to log in to the server with xrdp+xfce!
MAC USERS
Install Microsoft Remote Desktop Client from MAC APP STORE
WINDOWS USERS
Windows users may already know that their system has a client pre installed in their system. Just click windows button then search on cortana RDP. It will immediately show up the Microsoft Remote Desktop Connection.
Just Click on that and put your server IP and enter.
That’s All! Then type in the user and its password which we made earlier above!
;)
BY DEFAULT THE MAIN TERMINAL WILL NOT WORK IN XFCE. YOU HAVE TO SEARCH FOR XFCE TERMINAL IN APPLICATION FINDER WHICH WE HAVE INSTALLED EARLIER.
Customization(Optional!)
- Installing Xfce4-screenshooter to take screenshots and upload it to sites like imgur directly
sudo apt-get install xfce4-screenshooter
Then, right click on the and Add New Item. It will open a windows to select app. Scroll down to find “Screenshot”. And then select it and click Add.
Now, you will be able to see the screenshot button at the top right corner as shown below.
Now whenever you have to take screenshot of your server during the xrdp session then just click on that screenshot button and upload it to imgur to access it on your local desktop!
2. Customizing Terminal Welcome Message
First install figlet
sudo apt-get install figlet
Then, install nano to edit text files
sudo apt-get install nano
Then, type in the command to open and edit .bashrc file which contains the welcome message
sudo nano ~/.bashrc
It will give you a output like this
Now press enter to shift everything by one line and type the below thing on the starting line (Change YOUR_WELCOME_MESSAGE with your message)
figlet "YOUR_WELCOME_MESSAGE"
Now press Ctrl+X and then type Y and then Press Enter.
Done!
Now exit the console and reopen.
Have Any Doubt then Post a response in comments. Or wanna show me your results then feel free to add a response!