How to install VNC Server on CentOS

Virtual Network Computing or VNC is a graphical-based tool that can help you to control a computer remotely. This guide shows you how to setup and configure VNC on CentOS.

Virtual Network Computing or VNC is a graphical-based tool that can help you to control a computer remotely. The computer being controlled is termed as VNC Server, and the machine that’s controlled from is called a VNC Client.

In this tutorial, we are going to cover how to install and configure a VNC Server on CentOS machine. Also, at the end of this tutorial, we will show you how to connect to a VNC Server.

Installing VNC Server on CentOS

Step 1. Before starting in the installation of the VNC Server, we need first to make sure you have a graphical Desktop installed on your CentOS machine.

To get your currently installed graphical Desktop name use the next command:

echo $XDG_CURRENT_DESKTOP

Check Currently Installed Desktop
Check Currently Installed Desktop

In case you have no graphical Desktop installed, use the following command to install the Gnome Desktop:

sudo yum groupinstall "GNOME Desktop"

Step 2. To install a VNC Server, we will install the “tigervnc-server” package. Also, we will install some other dependency package.

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

Install Tigervnc Package
Install Tigervnc Package

Step 3. To configure the VNC Server, we will copy the VNC configuration file that is located in “/lib/systemd/system/vncserver@.service” to the new location “/etc/systemd/system/vncserver@:<Port_Number>.service”. Where the <Port_Number> is the port number that we need the VNC service to listen on. We can specify the port number using one of the next methods:

/etc/systemd/system/vncserver@:5903.service
OR
/etc/systemd/system/vncserver@:3.service

Next, we will copy the VNC configuration file using the next command:

sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:3.service

Copy The VNC Server Configuration File
Copy The VNC Server Configuration File

Step 4. Edit the VNC configuration file using your favorite editor.

sudo vi /etc/systemd/system/vncserver@:3.service

Open The VNC Server Configuration File
Open The VNC Server Configuration File

Then replace the user tag with the user that will be able to remotely control the desktop via the VNC client like the below screenshot.

Edit The VNC Server Configuration File
Edit The VNC Server Configuration File

Step 5. Add a new firewall rule using the next command.

sudo firewall-cmd --permanent --zone=public --add-port=5903/tcp

Add Firewall Rules
Add Firewall Rules

Then reload the firewall using the following command.

sudo firewall-cmd --reload

Reload New Firewall Rules
Reload New Firewall Rules

Step 6. Now switch to the user whom you set in the VNC configuration file. Then execute the next command to set the password for VNC client authentication.

vncserver

Set A VNC Password
Set A VNC Password

Step 7. Next, start the VNC service and enable it at the boot.

sudo systemctl daemon-reload
sudo systemctl start vncserver@:3.service
sudo systemctl enable vncserver@:3.service

Enable VNC Server At Boot
Enable VNC Server At Boot

Step 8. Finally, get the machine IP using the next command.

ifconfig

VNC Server IP
VNC Server IP

Step 9. Now to test VNC Server, from your Windows machine and using the VNC viewer. Enter your VNC Server IP and port like the below screenshot.

Connecting To VNC Server
Connecting To VNC Server

Press continue button to skip the unencrypted connection warning.

VNC Encryption
VNC Encryption

Next, enter the VNC password and press OK.

Password Authentication For VNC
Password Authentication For VNC

Finally, you will be able to access the VNC Server.

Connected To VNC Server
Connected To VNC Server

Congratulations you have installed and configured the VNC Server on your CentOS machine. Now you can start exploring your CentOS remotely.

Hend Adel
Hi! I'm Hend Adel, a freelancer technical geek with successful experience in Database, Linux and many other IT fields. I help to build solutions to suit business needs and creating streamlined processes. I love Linux and I'm here to share my skills via FOSS Linux! Thanks for reading my article.

1 COMMENT

  1. Hi,

    I keep getting this error:

    [remoteuser@localhost tmp]$ vncserver

    WARNING: The first attempt to start Xvnc failed, possibly because the font
    catalog is not properly configured. Attempting to determine an appropriate
    font path for this system and restart Xvnc using that font path …
    Could not start Xvnc.

    _XSERVTransSocketUNIXCreateListener: …SocketCreateListener() failed
    _XSERVTransMakeAllCOTSServerListeners: server already running
    (EE)
    Fatal server error:
    (EE) Cannot establish any listening sockets – Make sure an X server isn’t already running(EE)
    _XSERVTransSocketUNIXCreateListener: …SocketCreateListener() failed
    _XSERVTransMakeAllCOTSServerListeners: server already running
    (EE)
    Fatal server error:
    (EE) Cannot establish any listening sockets – Make sure an X server isn’t already running(EE)

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,241FansLike
399FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

MUST READ

“I am because you are,” is the themed meaning behind the famed Ubuntu operating system. Moreover, this mindful phrase is practical because it continues to lure more individuals into the Ubuntu universe. Because great power beckons great responsibility, Ubuntu is stepping up. It realizes that different users will want to use the Ubuntu operating system software differently.
The Ubuntu Cinnamon Remix brings together Linux Mint's Cinnamon desktop with the Ubuntu Core. While some users are welcoming the new flavor of Ubuntu with open arms, others are scratching their heads, wondering where it fits in.

10 Reasons to use Cinnamon as your Desktop Environment

With the release of Gnome 3 in 2011, there was quite a mixed reaction from users and developers. Most of them preferred the original Gnome that got forked, and one of those forks was Cinnamon. Since the release of Cinnamon 2.0, Cinnamon has evolved to become a desktop environment by itself.

The 10 Best Linux Hex Editors

An Hex editor is a program that allows the user to view, edit, and manipulate binary files, which contain data that is readable by machines, but not humans. This is where hex editors come into play because unlike other programs and tools which interpret data from files, hex editors, on the other hand, offer the user an opportunity to edit the physical binary contents of a file.

How to dual-boot Ubuntu and Fedora on your PC

Every Linux distribution has its capabilities and preferences as per the user requirements. That brings forth the need to run different distros on one laptop. For example, a CyberSecurity enthusiast might prefer to use Ubuntu for development and Kali Linux for penetration testing.

Manjaro ‘Gellivara’ XFCE Edition (17.0.5) in 10 Screenshots

Want to take a quick virtual tour Manjaro XFCE edition instead of downloading GBs worth of ISO image and then making a Live USB of it? We will make it easy for you. Here are a series of screenshots of the important aspects of Manjaro Linux in XFCE edition. This is a light-weight edition, and aims to be fast and low on system resources. You will be amazed on how it is still visually appealing and user friendly.