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/[email protected]. We need to copy /lib/systemd/system/[email protected] to /etc/systemd/system/[email protected]: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).

$ cp /lib/systemd/system/[email protected]  /etc/systemd/system/[email protected]:1.service

Next, we will add user information in the configuration file. So we will add a user named ‘vncuser’ for accessing vnc

$ useradd vncuser

Now open /etc/systemd/system/[email protected]:1.service,  & add user information  (see screenshot)

$ vi /etc/systemd/system/[email protected]:1.service

vnc

Next, we will assign a password to access the VNC server,

$ su vncviewer
$ vncserver

You will be asked to enter a password & then confirm it & some files will be created after that.

Our VNC server is now ready to be used, we will restart service & enable it , so it can restart on every reboot,

$ systemctl daemon-reload
$ systemctl start [email protected]:1.service
$ systemctl enable [email protected]:1.service

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

vnc

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/[email protected]:1.service to /etc/systemd/system/[email protected]:2.service or /etc/systemd/system/[email protected]: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 :-

Connect to us: Facebook | Twitter | Google Plus

Become a Supporter – Donate us some of you hard earned money:

Linux TechLab is thankful for your continued support.

Shusain

Passionate about Linux & open source. Loves to learn, read & write about Linux as well as new technologies.

You may also like...

Leave a Reply

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