In this tutorial we’ll learn how to install VNC on CentOS 7. We will also install and configure its prerequisites. VNC (Virtual network computing) is a graphical desktop sharing system which will allow you to connect to a computer, view its graphical interface and control it remotely using a VNC client. It makes managing files, software, and settings on a remote server easier for users who are not yet comfortable with the command line.
I recommend to use a minimal CentOS server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.
Install VNC on CentOS 7
Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:
yum clean all yum install epel-release -y yum update -y
Step 2. Installing VNC.
First, install Graphical Desktop Environment using YUM command:
yum -y groupinstall "GNOME Desktop" "Graphical Administration Tools"
Next, install the tigervnc server and X11 fonts:
yum -y install tigervnc-server xorg-x11-fonts-Type1
Step 3. Configure VNC Server File.
Add a VNC service configuration file for your user via a daemon configuration file placed in systemd directory tree:
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:5.service
Edit the user’s information in the config file:
Find these lines:
ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i" PIDFile=/home/<USER>/.vnc/%H%i.pid
Replace (username as chedelics):
ExecStart=/sbin/runuser -l rezkia -c "/usr/bin/vncserver %i" PIDFile=/home/rezkia/.vnc/%H%i.pid
Start VNC server after switching to chedelics:
Set the password:
You will require a password to access your desktops. Password: Verify: xauth: file /home/rezkia/.Xauthority does not exist New 'localhost.localdomain:1 (rezkia)' desktop is server.myvpsource.com:1 Creating default startup script /home/rezkia/.vnc/xstartup Starting applications specified in /home/rezkia/.vnc/xstartup Log file is /home/raj/.vnc/server.myvpsource.com:1.log
Then, Start and Enable the VNC Service at boot:
systemctl daemon-reload systemctl start vncserver@:5.service systemctl enable vncserver@:5.service
Step 4. Set the Firewall Rule.
Add firewall rules to allow the VNC connection:
firewall-cmd --permanent --zone=public --add-port=5905/tcp firewall-cmd --reload
Step 5. Testing the VNC.
You have to check your VNC. You have to connect to the remote server using SSH connection and forward the connection to the localhost connection:
ssh -L 5901:127.0.0.1:5905 -N -f -l username server_ip_address
If you are using Windows, install TightVNC and Putty.
Congratulation’s! You have successfully install and configured VNC on your CentOS 7 server. Thanks for using this tutorial for installing VNC remote dekstop on CentOS 7 system.