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.
You 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 again
x11vnc --reopen --forever -rfbauth ~/.vncpasswd &
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/vncserver@.service /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) Teamviewer
Teamviewer 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) FreeNX
FreeNX 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.
Thanks for the info! But, there's a typo under x11vnc: "~/.vncpasswd ".
Subtle error - everything runs, but remote authentication always fails.
Thanks for that.
Yes this error still exists. I ran into the error too.
Just a missing / line should read
x11vnc --reopen --forever -rfbauth ~/.vnc/passwd &
passwd file is in hidden .vnc folder
Thanks for your write-up.
Personally, I find xrdp to be quick and efficient, both to and from Linux and Windows boxen.
Also, X2go might be a replacement for FreeNX.
This was helpful for me to get xrdp seup for CentOS 7. I had to add a step to configure the firewall:
firewall-cmd --permanent --add-port=3389/tcp
firewall-cmd --reload
Thanks
Thanks for inputs
can I install more than one tool to Enable Remote Desktop Access on centOS ?
tried with Tigervnc server it works bun have a bug in log screen , I want to try Xrdp together but don't know if I can
Yes, you can. Good to stop tigervnc service
Thank you for the above list. R-HUB remote support servers is another very good remote support tool which is used by businesses globally for remotely accessing computers. It works well.
It would be helpful to clearly state which machine (local or remote) a particular command is run on.
in part #2 TigerVNC required "vncpasswd" command or the service fails to start.
in your #3 XRDP need some sort of vnc running for it, so #1 or #2 is kind of prerequisite for this to work at all.
Not quite sure about your #5 "FreeNX" software name (failed to find it), but I tried something called "NoMachine" from NoMachine, and it works perfectly well...
Thank you for your input. It's fixed now. Nomachine is a good choice we have included in 12 Best Tools to Connect Linux Remote Desktop.