Summary

Xrdp allows GUI access to Amazon Linux 2 using Xvnc as a backend, usefull for customers who require GUI access and workspaces is not an option.

Main Text

Prerequisites

Make sure that your system is up to date and reboot in case of a new kernel release

sudo yum update -y
sudo reboot

Install build tools and Xrdp dependencies

sudo yum group install -y "Development Tools" 
sudo yum install -y tigervnc-server openssl-devel pam-devel fuse-devel pixman-devel nasm \ libX11-devel libXfixes-devel libXrandr-devel

Install a minimal GUI

sudo yum install -y xterm gnome-shell gnome-session nautilus  # minimal GUI

Compilation & Installation

Check the latest release at the project github page.

wget https://github.com/neutrinolabs/xrdp/releases/download/v0.9.11/xrdp-0.9.11.tar.gz
tar axfv xrdp-0.9.11.tar.gz
cd xrdp-0.9.11/

Run the following to compile the source files, please note it’s highly recommneded to specify a –prefix to keep your manually compiled filed isolated form the system packages.

./configure --prefix=/opt/xrdp \
            --sysconfdir=/etc  \
            --enable-fuse      \
            --enable-pixman    \
            --enable-painter   \
            --with-systemdsystemunitdir=/usr/lib/systemd/system
make V=0
sudo make install

Configuration

The following configuration files are needed to make sure Xrdp works with Amazon Linux 2

1-  /etc/xrdp/xrdp.ini

Comment out the Xorg block  in line 181 to 188 should look like this

#[Xorg]
#name=Xorg
#lib=libxup.so
#username=ask
#password=ask
#ip=127.0.0.1
#port=-1
#code=20

Note that you can also swap this block with the Xvnc one below it.
2- /etc/xrdp/startwm.sh

modify line 77 should look like this

# el
   if [ -r /etc/X11/xinit/Xsession ]; then
     pre_start
     . /etc/X11/xinit/Xsession gnome
     post_start
     exit 0
   fi

As you can see we just added gnome.

Starting

Enable and start xrdp

sudo systemctl enable --now xrdp 

Confirm its running and listening to rdp port

$ sudo lsof -Pnli:3389 
COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
xrdp    9507        0   11u  IPv4 173903      0t0  TCP *:3389 (LISTEN)

Now you can use any RDP client to login using a user that has a password.

To connect using windows, open up an RDP session and add the public ip of your instance and thats it.

Source:

The steps above was provided by my colleagues Asem and Luke, thanks a million guys

Leave a Reply

Your email address will not be published. Required fields are marked *