Ubuntu Xrdp Server Config and Auto Startup (Remote Desktop)
By: Asel Siriwardena
Tags: Windows, Remote Server, Remote Desktop, Ubuntu

Ubuntu Xrdp Server Config and Auto Startup (Remote Desktop)

image by Christina @ wocintechchat.com

Hi, I’m Asel, In this article, I’m going to show you how I manage to use one monitor with my laptop and workstation hassle-free. From this method, you can use your Ubuntu desktop from a laptop anywhere in your home/office.

As I mentioned before I wanted to use my monitor for my laptop while using my workstation. For that, I found two options.

SSH

RDP

SSH into my machine is a nice way but I wanted a get my desktop experience. Sometimes it’s very useful. The most awesome thing is you can copy it to a clipboard and past it to your ubuntu machine and of cause if your ubuntu machine is powerful than your laptop you can open all chrome tabs on it. Like that it has some nice benefits. Okay, let’s get started.

Configuring Ubuntu

First, you need to install xrdp tool for Ubuntu using terminal (Ctrl+Alt+T).

sudo apt install xrdp

Adding a Startup script

Then you will need to save the following script in a sh file using. This will start the xrdp server and allow windows to connect from port 3389.

sudo systemctl enable --now xrdp

sudo ufw allow from any to any port 3389 proto tcp

Note that adding the following rule will disable asking permission in the login. If your network isn’t secure skip the next step.

create a polkit configuration file.

sudo nano /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf

Past these lines and press ctrl+X for exit from nano editor.

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(“{group}”))

{

return polkit.Result.YES;

}

});

There are two ways to add a startup script to your system. First I'll show you the GUI way, and then the command-line way.

Using GUI

Now we need to execute this script every time we turn on our ubuntu pc. otherwise, we have to connect a monitor and execute it manually. For that, we have to add that script to startup applications in ubuntu. Search for “startup” you will find it. locate your saved script file and save.

adding startup program — ubuntu

Using Command-Line

You can add a @reboot cron task by executing the following command and adding the script path.

crontab -e

now add the following line to it

@reboot /path/to/script

Getting ubuntu machines IP

Then We need to get the IP of your ubuntu machine to connect from windows. for that execute following in the terminal.

ifconfig

Connecting From Windows

Search for a remote desktop on your PC and enter the ubuntu IP address to connect. Use an existing user account for login. Finally, click connect.

Windows remote desktop

Troubleshooting

If you are unable to execute commands like shutdown or restart try them with sudo. That will work.

If you got a black screen after connecting to the ubuntu machine that means you are using a user account that already being signed in. Sign out from the ubuntu machine you are good to go.

Ubuntu desktop from xrdp

Thanks for reading. I believe this will be helpful.