6 Steps to install VNC Server on Centos 7

In this article, I am going to introduce three main things.
1. How to install and configure a VNC Server on Centos 7.
2. How the VNC client connect to a VNC Server.
3. Troubleshooting.

Install and configure a VNC Server on Centos 7

I assume you have a graphical Desktop installed on your CentOS machine.

STEP 1:About User

It’s very common to share an machine with other colleagues in company. So maybe you need to create an user for yourself and use this user to run the VNC program. Please go step 2 If you have already login with the user you want to run the VNC program.

adduser [username]
passwd [username]
su - username

STEP 2: Install Tigervnc-server

In order to install a VNC Server, we need to install “tigervnc-server” package.

Method 1: Using yum to install tigervnc-server. It is very easy but also very easy to fail to download the tigervnc-server package. because the mirror is not reachable.

sudo yum install tigervnc-server

Method 2: Download “tigervnc-server-1.8.0-17.el7.x86_64.rpm” package first.
Then, using the following command to install it.

sudo rpm -i tigervnc-server-1.8.0-17.el7.x86_64.rpm

STEP 3: Copy and Modify Configuration File

Copy the vncserver@.service to vncserver@:[portnum].service. The postnum can be 3. Its corresponding TCP port is 5903.

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

After copy the configuration file to right place. We need to modify the configuration file. Replace “<USER>” to the username which you create in STEP 1. Total two places need to be replaced.

STEP 4: Set Firewall

Using the following command to set a new firewall  rule.

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

Reload the firewall.

sudo firewall-cmd --reload

STEP 5: Setting Password

Using the following command to set the password for VNC client authentication.

vncserver

STEP 6: Start and Enable VNC Server

Using the following commands to start and enable VNC server.

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

How the VNC Client Connect To a VNC Server

STEP 1: Download VNC viewer

Download the VNC viewer. And install it like the other software.

STEP 2: Set Connection

Click File button on the top left corner. Then click New connection.

In the dialog box, we only need to do three things like Figure 1 shows.

  1. Enter your VNC server like this: [IP address]:[portnumber], for example, 10.0.0.1:3.
  2. Encryption: Select Let VNC Server choose.
  3. Remove the selection of both checkboxes in Security
Figure 1

STEP 3: Enter Your Password

Enter your password which we set in the install and configurate VNC server stage.

Done. You can login into your remote linux system. Congratulation.

Troubleshooting

I have met three problems when I installed and connected to VNC Server.

Problem 1: Can’t start VNC Server.

Answer: Because I didn’t set a new firewall rule and reload it.

Problem 2:When I created a new user which used to connect VNC server and execute sudo commands, but it is not the sudoers file.

Answer: Using the following command to add your new user to sduoers file.

echo '[your username] ALL=(ALL) ALL' >> /etc/sudoers

Problem 3: When I used VNC client to connect VNC server. I always got the timeout or other errors.

Answer: Root cause is that I have used a VPN. Thus, remove VPN when I use VNC client. or add the VNC server address to VPN to filter this IP address.

I believe you also have installed and connected VNC server successfully.

I am really appreciate the following two articles, helo me a lot.

Reference:
1. How to install VNC Server on CentOS
2. How to Install and Configure VNC Server in CentOS 7

Share this article to your social media
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments