xrdp provides a graphical login to remote machines using Microsoft Remote Desktop Protocol (RDP).

This tutorial shows you how to install and configure Xrdp server on Ubuntu 20.04 so that you can login to remote ubuntu 20.04 in Windows 10 using remote desktop connection.

Install one DE (desktop environment)

If you are using Ubuntu Desktop ,or using Ubuntu Server but already has a DE installed you can skill this step.

  • Install Gnome

    sudo apt install tasksel
    
    sudo tasksel install ubuntu-desktop
    
    sudo reboot
    

OR

  • Install xfce4

    sudo apt update;sudo apt install xfce4
    

Install xrdp

  • install xrdp from ubuntu office repository

sudo apt install xrdp 
  • add user xrdp into group ssl-cert

    Because xrdp need to use /etc/ssl/private/ssl-cert-snakeoil.key whose unix group is ssl-cert , so we need to add xrdp into this group

    root@ubuntu2004:~# ls -l /etc/xrdp/key.pem 
    lrwxrwxrwx 1 root root 38 Aug  7 18:51 /etc/xrdp/key.pem -> /etc/ssl/private/ssl-cert-snakeoil.key
    root@ubuntu2004:~# ls -l /etc/ssl/private/ssl-cert-snakeoil.key
    -rw-r----- 1 root ssl-cert 1708 Jan  4  2021 /etc/ssl/private/ssl-cert-snakeoil.key
    
    adduser  xrdp ssl-cert
    
  • Restart xrdb

    sudo systemctl restart xrdb
    

Some configuration

  • Firewall configuration

    sudo ufw status
    

    If your firewall status is active ,then open xrdp port 3389

    sudo ufw allow 3389
    
    sudo ufw reload
    
  • modify /etc/xrdp/startwm.sh to avoid black screen

    sudo vi /etc/xrdp/startwm.sh
    

    Add below 2 lines before test -x /etc/X11/Xsession && exec /etc/X11/Xsession

  unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR



  • For xfce4 only

    echo xfce4-session >> ~/.xsession
    

Connect to Ubuntu via remote desktop connection

In Windows now you can open windows remote connection , input your remote ubuntu’s IP/DNS


Enter your ubuntu’s username and password , you should be able to connect to Ubuntu via RDP now.

If you want to terminate RDP session just logout from gnome or xfce4.

If you are not using Windows but using Mac Os or Linux you can use one of below RDP clients:

  • FreeRDP
  • rdesktop
  • KRDC
  • NeutrinoRDP
  • Windows MSTSC (Microsoft Terminal Services Client, aka mstsc.exe)
  • Microsoft Remote Desktop (found on Microsoft Store, which is distinct from MSTSC)