In this tutorial, we will show you how to install VNC Server on CentOS 7. For those of you who didn’t know, VNC (Virtual Network Computing) server is free and open-source software that is designed for allowing remote access to the Desktop Environment of the server to the VNC Client whereas the VNC viewer is used on the remote computer to connect to the server.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you the step-by-step installation VNC server on CentOS 7.
Prerequisites
- A server running one of the following operating systems: CentOS 7.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install VNC Server on CentOS 7
Step 1. First, you need to update the system to ensure that we have all of the latest software installed.
yum update
Step 2. Install the Gnome desktop.
yum groupinstall "GNOME Desktop"
Step 3. Install Tigervnc server and X11 fonts.
yum install tigervnc-server xorg-x11-fonts-Type1
Copy the VNC server configuration file /etc/systemd/system/
for configuring the system service. While copying, you can mention which port it should listen to. By default VNC server listens on 5900:
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:5.service
Edit VNC server file configuration:
nano /etc/systemd/system/vncserver@:5.service
## Replace <USER> with your real user, in my case i replaced with user called “idroot” with the screen size ## [Unit] Description=Remote desktop service (VNC) After=syslog.target network.target[Service] Type=forking # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’ ExecStart=/sbin/runuser -l idroot -c “/usr/bin/vncserver %i -geometry 1280×1024″ PIDFile=/home/idroot/.vnc/%H%i.pid ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'[Install] WantedBy=multi-user.target
Step 4. Configure firewall rules to allow the VNC connection.
firewall-cmd --permanent --zone=public --add-port=5905/tcp firewall-cmd --reload
Step 5. Start the VNC server.
vncserver
Set the password.
You will require a password to access your desktops. Password: Verify: xauth: file /home/idroot/.Xauthority does not exist New ‘localhost.localdomain:1 (idroot)’ desktop is server.idroot.us:1 Creating default startup script /home/idroot/.vnc/xstartup Starting applications specified in /home/idroot/.vnc/xstartup Log file is /home/idroot/.vnc/server.idroot.us:1.log
Step 6. Enabling and starting the VNC service
Reload the systemctl
daemon as root.
systemctl daemon-reload
Start the VNC service as root:
systemctl start vncserver@:5.service
Enable it on system startup as root:
systemctl enable vncserver@:5.service
Step 7. Now you can able to connect the VNC server using IP and Port ( Eg: 192.168.2.109:5 ) and you will be asked to enter the password, and enter the password that you have created earlier.
Congratulations! You have successfully installed the VNC server. Thanks for using this tutorial for installing the VNC server on CentOS 7 system. For additional help or useful information, we recommend you check the official VNC website.