Install and Configure VNC console in Centos7

Windows Articles

Install GLPI with Lighttpd on Ubuntu 20.04

Ubuntu 20.04 is a very popular distribution on servers because it is quite stable and offers commercial support. That is why it...

How to install Lighttpd on Ubuntu 20.04?

There are many web services in Unix but we always look for the one that best suits our needs. In this case,...

How to install Docker on Ubuntu 20.04 / Debian 10?

Docker is a fairly popular technology in today's sysadmin. It is logical to think because it means a complete change in the way images...

How to install Mantis Bug Tracker on Ubuntu 20.04?

Hi, folks. In this post, I will help you to install Mantis Bug Tracker on Ubuntu 20.04 If you...

How to install WordPress with Nginx on Ubuntu 20.04?

Hi, folks. In this post, we will help you install Wordpress with Nginx on Ubuntu 20.04. It's a lot easier than you...
Muhammad Nabeel
Muhammad Nabeel
Network and System Administrator

In this article you will learn how to install and configure VNC in Centos and RHEL

VNC (Virtual Network Computing) is a protocol which is used to remotely access user accounts by the Graphical User Interface.

Step 1: Install VNC

You need to use following command in order to install VNC. Makse sure you are login as root user.

# yum install tigervnc-server -y

Step 2: Setup VNC Password

After installation, login with the user you want to allow VNC remote access and and set VNC password for that user. I will enable VNC access to root user.

 

# su - user_name

# vncpasswd

Step 3: VNC Configuration

Now create a VNC file for your user. I template file vncserver@.service placed in below mentioned path, we will use copy of that file and make configuration for VNC user.

/lib/systemd/system/vncserver@.service

Use following command to make copy of vncserver@.service file.
Note: New file will be named as vncserver@:1.service

# cp /lib/systemd/system/vncserver@.service   /etc/systemd/system/vncserver@:1.service

 

Number 1 after @ sign represents the display number (port 5900+display). Secondly the port 5900 will be incremented by 1 with each started VNC server.

Now edit vncserver@:1.service file using following command.

# vi /etc/systemd/system/vncserver@\:1.service

and add the below lines in this file. Replace your_user with your username.

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l your_user -c "/usr/bin/vncserver %i
PIDFile=/home/You_user/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

save changes to file and quite

Step 4: Reload Necessary Daemons

After changes in file, reload systemd program to load new VNC configuration file and start the VNC server. Use following commands

# systemctl daemon-reload

# systemctl start vncserver@:1

# systemctl status vncserver@:1

# systemctl enable vncserver@:1

Step 5: Add Ports in Firewall

You must add VNC open ports in firewall so VNC client can access the system.
Use below command to list listening ports of VNC server

# ss -tulpn| grep vnc

Note: If you started multiple VNC instances for different users, the port value will be 5902 for the second, 5903 for the third and so on.

Use followings commands to add ports and reload firewall.

# firewall-cmd --permanent --add-port=5901/tcp

# firewall-cmd --reload

Step 6: Connect to CentOS Desktop from VNC Client

In order to access Centos desktop you need to install a VNC Client program, then run VNC Client and add the IP address and port number of CentOS VNC server and press enter button.

After that a warning will be displayed, click on continue button and enter VNC password on new screen.

Congratulations! You have access your Centos Desktop from VNC.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Install GLPI with Lighttpd on Ubuntu 20.04

Ubuntu 20.04 is a very popular distribution on servers because it is quite stable and offers commercial support. That is why it...

How to install Lighttpd on Ubuntu 20.04?

There are many web services in Unix but we always look for the one that best suits our needs. In this case,...

How to install Docker on Ubuntu 20.04 / Debian 10?

Docker is a fairly popular technology in today's sysadmin. It is logical to think because it means a complete change in the way images...

How to install Mantis Bug Tracker on Ubuntu 20.04?

Hi, folks. In this post, I will help you to install Mantis Bug Tracker on Ubuntu 20.04 If you...

How to install WordPress with Nginx on Ubuntu 20.04?

Hi, folks. In this post, we will help you install Wordpress with Nginx on Ubuntu 20.04. It's a lot easier than you...