Save 10%Pay yearly on any plan. 6% half-yearly, 3% quarterly. Help centreWhatsAppTelegram TeamsOpen a ticket

Connecting to an Ubuntu Server Through RDP

Set up xrdp on Ubuntu Server, connect from Windows, macOS or Linux with a Remote Desktop client, fix the black screen, and keep port 3389 off the open internet.

3 min readBy Shailabh

Reviewed by the AmazingRDP technical team

Connecting to an Ubuntu server through RDP

A Linux VPS with 2 GB or more runs Xfce and xrdp comfortably. See Linux VPS from $6.99

Remote Desktop (RDP) is Windows' way of showing a remote screen, and Ubuntu can speak it too, through a free program called xrdp. With it you connect to an Ubuntu server using the same Remote Desktop client you use for Windows. The server needs a desktop environment for there to be something to show.

1. Install a desktop and xrdp

sudo apt update
sudo apt install xfce4 xfce4-goodies xrdp

Xfce is the desktop that works best with xrdp: light, and built for the X11 system xrdp uses. For other desktops and their memory needs, see how to install a desktop on an Ubuntu server.

2. Two small settings

sudo adduser xrdp ssl-cert
echo "startxfce4" > ~/.xsession
sudo systemctl restart xrdp
sudo systemctl enable xrdp

The first line lets xrdp read the certificate it encrypts with. The second tells it which desktop to start for your user; every user who will connect needs that file in their own home folder.

3. A user to sign in with

Do not use root for a desktop. If the server only has root:

sudo adduser alex
sudo usermod -aG sudo alex

Then sign in as that user once over SSH and create the .xsession file from step 2.

4. Open the port, carefully

RDP uses TCP port 3389, which bots on the internet probe all day. Allow it for your own address only:

sudo ufw allow from 203.0.113.10 to any port 3389 proto tcp

If your address changes often, keep the port closed and use an SSH tunnel. On your PC:

ssh -L 3390:127.0.0.1:3389 alex@SERVER_IP

and connect the Remote Desktop client to 127.0.0.1:3390.

5. Connect

FromClient
WindowsRemote Desktop Connection (press Win + R, type mstsc)
macOS, iPhone, AndroidMicrosoft's Windows App
LinuxRemmina

Enter the server's address, accept the certificate warning (the server made its own certificate), and at the xrdp login window choose session Xorg and enter your Linux user name and password. The Xfce desktop appears. More on the client is in how to connect to RDP from a desktop.

Problems and fixes

  • A black or blank screen after login. The ~/.xsession file is missing for that user, or names a desktop that is not installed.
  • The window closes right after login. The same user is signed in on the server's own screen or in another desktop session. One user, one graphical session: sign out there, or use a separate user.
  • "Authentication is required to create a color managed device". A harmless prompt on some versions; cancel it.
  • Slow or jerky. In the client, lower the colour depth to 16 bit and switch off wallpaper and animations; in Xfce, turn off the compositor under Window Manager Tweaks.
  • Cannot connect at all. Check sudo systemctl status xrdp, and that the port is reachable: how to check open ports on Ubuntu.

Change the port

Edit /etc/xrdp/xrdp.ini, change port=3389, and restart xrdp. Another port reduces noise in the logs. It is not protection; the firewall rule is.

xrdp or VNC?

xrdp is usually the smoother of the two and needs no extra viewer on Windows. VNC shares an existing screen and works with any desktop: see how to install a VNC server on CentOS for that route.

RDP to Linux, or a Windows remote desktop?

If you need Linux programs with windows, this setup on a Linux VPS is right. If what you want is a Windows desktop in the cloud, a Windows RDP plan gives you that directly, with nothing to install. Related: Xfce vs GNOME and open or block a port in the Ubuntu firewall.

Questions

Can I use Remote Desktop to connect to Ubuntu?

Yes. Install xrdp and a desktop environment on Ubuntu, then connect with any RDP client.

Why do I get a black screen with xrdp?

Usually the file ~/.xsession is missing, or the same user already has a desktop session open.

Which port does xrdp use?

TCP 3389, the standard RDP port.

Is xrdp secure?

The connection is encrypted, but the port should not be open to everyone. Allow only your address or use an SSH tunnel.