5 Tools to Enable Remote Desktop Access on RHEL/CentOS 7
Abstract: # yum install teamviewer.x86_64.rpm And set your password# yum -y install x11vnc Then we will protect server with password
In this tutorial, I will show you tools that enable you to access remote Desktop on machines running CentOS/RHEL. All these apps work in client-server mode. So you need to run a server-side app on your remote machine and after that, you will be able to connect to it from all over the world. Of course in this reference manual, I will tell you how to configure this securely, so only you can access your server.
Before we begin, you will need SSH access to your server and permissions to install the software. You will need to login as the root user or user with the sudo privileges. All commands will work on every CentOS server 5/6/7/8. Before we start, you need to install desktop environment to your server.
# yum groupinstall 'GNOME Desktop Environment' 'X Window System'
1) VNC
x11vnc – simplest of these three methods to get remote access. VNC stands for Virtual Network Computing) is a very useful network graphics protocol.
Enable Remote Desktop - RemminaTo view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video
Enable Remote Desktop - RemminaYou need to enable EPEL (Extra Packages for Enterprise Linux) repository. Run
# yum -y install epel-release
Now we can install x11vnc. This command will install server and solve all dependencies:
# yum -y install x11vnc
Then we will protect server with password:
# x11vnc -storepasswd
Enter VNC password:
Verify password:
Write password to /root/.vnc/passwd? [y]/n y
Password written to: /root/.vnc/passwd
!Do not use simple passwords!
We are now ready to start server:
# x11vnc --reopen --forever -rfbauth ~/.vncpasswd &
You can check if servers started:
# netstat -an | grep 5900
tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN
tcp6 0 0 :::5900 :::* LISTEN
If it is ok, simply try to connect to it using vncviewer.
# yum -y install vnc
# vncviewer YOUR_SERVER_IP
That's all! Now you have access to your desktop. After reboot just ssh again and do it again.
x11vnc --reopen --forever -rfbauth ~/.vnc/passwd &
2) TigerVNC server
TigerVNC - is a high-performance, platform-neutral implementation of VNC
# yum install -y tigervnc-server
Let's copy example config and edit it:
# cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
# vi /etc/systemd/system/vncserver@:1.service
Example of config:
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
Requires=systemd-logind.service
[Service]
Type=oneshot
RemainAfterExit=yes
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l USERNAME -c "/usr/bin/vncserver %i"
ExecStop=/usr/sbin/runuser USERNAME -c '/usr/bin/vncserver -kill %i'
[Install]
WantedBy=multi-user.target
NOTE: You must change the USERNAME in the above config if you'll use the same VNC setup. This is the configuration we used for this tutorial.
Now we must run vncpasswd command to setup our access password, and/or view-only password (a password that allows the user to only view the remote screen):
# vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
Now enable autostart service and restart it:
$ systemctl enable vncserver@:1.service
$ systemctl restart vncserver@:1.service
You can check the vnc service status by typing:
$ systemctl status vncserver@:1.service
If everything went ok, you should have similar terminal output to this:
$ systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
Active: active (exited) since Wed 2020-09-30 22:04:47 CEST; 7s ago
Process: 3766 ExecStart=/usr/sbin/runuser -l slax -c /usr/bin/vncserver %i (code=exited, status=0/SUCCESS)
Process: 3761 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
Main PID: 3766 (code=exited, status=0/SUCCESS)
Sep 30 22:04:44 localhost.localdomain systemd[1]: Starting Remote desktop service (VNC)...
Sep 30 22:04:47 localhost.localdomain systemd[1]: Started Remote desktop service (VNC).
And finally connect to it:
# vncviewer YOUR_SERVER_IP
3) XRDP
XRDP is an Open Source Remote desktop Protocol server. In order to use XRDP you need to have VNC service already installed. So you should follow the first or second option from this tutorial prior to XRDP installation.
First of all we need to install EPEL repository and xrdp server:
# yum -y install epel-release
# yum -y install xrdp
Now let's start service:
# systemctl start xrdp.service
Check if its running, and add it to autostart.
# netstat -an | grep 3389
tcp 0 0 0.0.0.0:3389 0.0.0.0:* LISTEN
# systemctl enable xrdp.service
Thats all. Now you can connect to your server from any Windows machine.
4) TeamviewerTeamviewer does not exist in standard repos, so we need to install wget and download TeamViewer rpm package
# yum -y install wget
# wget https://download.teamviewer.com/download/linux/teamviewer.x86_64.rpm
Install it using this command:
# yum install teamviewer.x86_64.rpm
And set your password:
# teamviewer passwd YOUR_PASSWORD
ok
# systemctl start teamviewerd.service
Now you only need to get your id to connect:
# teamviewer –info
TeamViewer ID: 9XXXXXXX7
Try to connect to it using this id and password you set before:
5) FreeNXFreeNX is a Remote Access solution based on enterprise-class open source technologies by NoMachine. If you want exactly this tool to get remote access, you may consider upgrading to cloud version.
First of all we need to add e EPEL + nux-dextop repositories, for Centos 6:
# rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm
For Centos 7
# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
Install server and agent:
# yum install freenx-server nxagent
Enable passdb authentication:
# echo 'ENABLE_PASSDB_AUTHENTICATION="1"' >> /etc/nxserver/node.conf
Now we need to create user for remote access and assign password for him:
# /usr/libexec/nx/nxserver --adduser bob
NX> 100 NXSERVER - Version 3.2.0-74-SVN OS (GPL, using backend: not detected)
NX> 1000 NXNODE - Version 3.2.0-74-SVN OS (GPL, using backend: not detected)
NX> 716 Public key added to: /home/bob/.ssh/authorized_keys2
NX> 1001 Bye.
NX> 999 Bye
#/usr/libexec/nx/nxserver --passwd bob
NX> 100 NXSERVER - Version 3.2.0-74-SVN OS (GPL, using backend: not detected)
New password:
Password changed.
NX> 999 Bye
Now we will install epel-repos and opennx client on your machine:
# yum install opennx
After starting opennx wizard you will be asked about the session name, server address, and port. Most important thing is to set up your key. You'll need to copy the key from server's /etc/nxserver/client.id_dsa.key and paste it into the general tab of your client session properties.
Please share your comments on this tutorial and let us know if you are aware of any other tools.