It might not make sense to use RDP to remote linux machines. The speed and performance all are not that good from my point to view. But in certain situation, you might need to use desktop on your remote Linux, then here comes this post.

1. CentOS 7

Commands to check system version:

uname -r
cat /proc/version
cat /etc/os-release
lsb_release -a
Note: lsb_release command sometimes does not work on CentOS

[root@centos7-1 ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

[root@centos7-1 ~]# cat /proc/version 
Linux version 3.10.0-1062.12.1.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Tue Feb 4 23:02:59 UTC 2020
[root@centos7-1 ~]# 

All commands :

[root@centos7-1 ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Preparing...                          ################################# [100%]
        package epel-release-7-12.noarch is already installed
[root@centos7-1 ~]# yum update && yum -y install xrdp tigervnc-server
[root@centos7-1 ~]# systemctl enable xrdp && systemctl restart xrdp
Created symlink from /etc/systemd/system/multi-user.target.wants/xrdp.service to /usr/lib/systemd/system/xrdp.service.
[root@centos7-1 ~]# 
 
[root@centos7-1 ~]# adduser netsec
[root@centos7-1 ~]# passwd netsec
Changing password for user netsec.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@centos7-1 ~]# usermod –aG wheel netsec 
[root@centos7-1 ~]# netstat -an | grep 3389
tcp        0      0 0.0.0.0:3389            0.0.0.0:*               LISTEN     
[root@centos7-1 ~]# 

Note: you don’t have to add user netsec into wheel group to log into remote CentOS server through xRDP. It is just put here to show the command.

There are lots of people online having a issue to log into CentOS using xRDP. It seems authenticated but RDP session closed right away after you logged into CentOS with right username and password on Windows machine. That is because they are missing “GNOME Desktop”

# yum groups -y install "GNOME Desktop"

or using light weight desktop Xfce:

# yum groups -y install "Xfce"

Under logging user’s terminal:

nano ~/.Xclients

Then copy & paste:

#!/bin/bash
XFCE="$(which xfce4-session 2>/dev/null)"
exec "$XFCE"

Make it executable:

chmod +x .Xclients

And restart the xrdp server:

sudo service xrdp restart

I still have no idea how to make it default to all users.

YouTube Video:

2. Ubuntu 18

Commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install ubuntu-gnome-desktop
sudo apt-get install -y xrdp
sudo sed -i ‘s/allowed_users=console/allowed_users=anybody/’ /etc/X11/Xwrapper.config
sudo nano /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf

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

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;
}
});
sudo apt-get install gnome-tweak-tool -y

YouTube Video for Installing GNOME Desktop GUI and xRDP on Azure Ubuntu 18.04:

Check your server’s public IP through command line:

[root@centos7-1 ~]# curl ifconfig.me
35.226.94.252
 

References

By Jon

Leave a Reply