Remote Desktop Connection (RDP, not VNC) From Ubuntu Laptop to Ubuntu Cloud Server

haRies Efrika
4 min readDec 28, 2021

There are bunch of tutorials out there explaining this, however they are missing some aspects that I finally ended up doing google and stack overflow again. Hope this article handles all.

There are at least two ways to do remote desktop connection to other Ubuntu system. Via VNC, and via RDP. This article specifically talks about the RDP, yes the same protocol used for Microsoft Windows platforms. On Ubuntu 20.04 installation you will find a client named Remmina which can handle both VNC and RDP connections. We will use that, beforehand we will setup the RDP capability on the server side.

Install xRDP on remote server

Login to your remote server and install some packages:

sudo apt install ubuntu-desktopsudo apt install xrdp

Afterwards, check if xrdp service is running well:

sudo service xrdp status

If you find a warning message like below:

Dec 28 14:31:50 ishar xrdp[3397067]: (3397067)(140393615636288)[DEBUG] Closed socket 7 (AF_INET 127.0.0.1:3389)
Dec 28 14:31:50 ishar systemd[1]: xrdp.service: Can't open PID file /run/xrdp/xrdp.pid (yet?) after start: Operation not permitted

It is completely fine, it may be caused by bug in the startup script which makes the PID file is checked before the service runs. After above warning lines you should see the following lines with no further error message.

...
Dec 28 14:31:51 ishar systemd[1]: Started xrdp daemon.
Dec 28 14:31:52 ishar xrdp[3397068]: (3397068)(140393615636288)[INFO ] starting xrdp with pid 3397068
Dec 28 14:31:52 ishar xrdp[3397068]: (3397068)(140393615636288)[INFO ] address [127.0.0.1] port [3389] mode 4
Dec 28 14:31:52 ishar xrdp[3397068]: (3397068)(140393615636288)[INFO ] listening to port 3389 on 127.0.0.1
Dec 28 14:31:52 ishar xrdp[3397068]: (3397068)(140393615636288)[INFO ] xrdp_listen_pp done

Please check with telnet if the port 3389 is accessible:

$ telnet localhost 3389Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

Ok we are good then. By default the xRDP configuration will open port 3389 on both IPv4 and IPv6, as well localhost and network IP (public or VPC or DHCP IP). For security reason we will open it for localhost only.

Edit file /etc/xrdp/xrdp.ini and change the following parts:

port=tcp://127.0.0.1:3389

It will force to only use IPv4 and bind the open port for localhost.

But if the service is only open for localhost, how could the client connect ?

For security reason we will use the SSH tunneling instead. Before trying to use Remmina to connect, first we will do SSH to our remote server using the following command:

$ ssh user@<remoteserver> -L 127.0.0.1:33000:127.0.0.1:3389

That command will open port 33000 on our PC, which will forward connection to remote server localhost port 3389.

After the SSH connection established, please test the open port from our client PC:

haries@thinkpad-x1:~/.ssh$ telnet localhost 33000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> quit
Connection closed.

Congratulations! Now we can securely connect to our remote server. Open the Remmina from Ubuntu desktop.

Click the (+) button on top left to create new profile.

  • Put any Name
  • set the protocol to RDP
  • For server address we will connect to our localhost port 33000
  • Resolution custom, click the […] to add desired resolution. I would suggest 720p for the balance between details and speed. If you don’t do this step, the default resolution will be 640x480.
  • Color depth 16bpp is enough and chosen for speed reason
  • Click save

Now we are ready to connect:

Simply double click the row to start connecting.

Login with preffered username and password (same like SSH), and voila! You will be asked what Desktop environment to use, in this example I was trying the LXQT because it is very lightweight and does not consume a lot of memory. From total 4GB Ram with Firefox open, I still have 2.5GB Ram free.

Thanks for reading, cheers 🍻!

— — —

--

--