Configuring VNC Server for GUI remote access

VNC or Virtual Network Computing is graphical desktop sharing tool. VNC server provides a duplicate of server display for the clients attached to it. A number of clients can be connected to using VNC.

In RHEL/CentOS 7, we use a package named “tigervnc-server” to setup VNC server. We will now start with installation but before we do that make sure that we have graphical version of OS installed. If that’s not the case, we will first install the graphical desktop,

$ yum groupinstall “GNOME Desktop”

If you already have graphical packages installed, skip this step & move onto installation of VNC-server.

Installation

We can install vnc server using the yum,

$ yum install tigervnc-server xorg-x11-fonts-Type1

Once the required packages have been installed, we will move to configuration part,

Configuration

Configuration file for VNC is /lib/systemd/system/vncserver@.service. We need to copy /lib/systemd/system/vncserver@.service to /etc/systemd/system/vncserver@:1.service, where :1 is used to denote port number 5901 . We can also assign it different port number like :2 or :3 (for 5902, 5903).

Note:- If you are getting an error while starting vnc service, reboot your system & try starting service then.

Testing the server

To test the vnc server, we require VNC-viewer to installed on the testing machine. I am using a Windows 10 machine with vnc-viewer installed.

Open vnc –viewer & enter the server address with port number

Next, you will get a warning if you are using an unencrypted connection, press “continue”

You will now be asked VNC password, enter the password to connect the session & you can see the display of the server.

If you want to add more user, repeat the whole process but change the port number from /etc/systemd/system/vncserver@:1.service to /etc/systemd/system/vncserver@:2.service or /etc/systemd/system/vncserver@:3.service & so on.

This concludes our tutorial on setting up VNC server on CentOS/RHEL 7. We will be back with more tutorials. Leave your comments/suggestions down below in the comment box.

If you think we have helped you or just want to support us, please consider these :-