Home / How To / How to install and configure VNC server on CentOS 8

How to install and configure VNC server on CentOS 8



VNC stands for "Virtual Network Computing" is a GUI desktop sharing program that can be used to access and control other computers over a network. It uses the Remote Frame Buffer protocol and works on a client / server model. Generally, it is used by technical support personnel to manage and troubleshoot desktops, servers and other network devices remotely.

In this tutorial we will show you how to install VNC server on CentOS 8.

Prerequisites

  • A system running CentOS 8 Desktop operating system.
  • A root password is configured on your server.

Getting Started

By default, SELinux is enabled in CentOS 8 operating systems and the VNC server does not work properly if SELinux is enabled. So it's a good idea to disable SELinux in your system. You can disable it by editing the following file:

  nano / etc / sysconfig / selinux 

Find the following line:

  SELINUX = maintain

And replace it with the following line:

  SELINUX = disabled

Save and close the file when you are done. Then restart the system to implement the changes.

Installing VNC Server

By default, TigerVNC is available in the CentOS 8 standard repository. You can install it by running the following command:

  dnf install tigervnc-server tigervnc-server-module -y 

When the installation is complete, you can proceed to the next step.

Create New User and Set VNS Password

Next, you must create a new user for the VNC Remote Desktop session. You can create a new user named hitesh as shown below:

  useradd hitesh 

Then you set the password for this user with the following command:

  passwd hitesh 

Then switch the user to hitesh and set the VNC password for this user with the following command:

  su - hitesh 
vncpasswd

Enter the desired password and press Enter to create the password shown below: [19659010] Password:
Verify:
Do you want to enter a display password (y / n)? n
A display-only password is not used

Then quit from the hitesh user with the following command:

  exit 

Create Systemd service file for VNC

Then you must create a systemd service file for VNC. You can create it with the following command:

  nano / etc / systemd / system / [email protected] 

Add the following lines:

  [Unit]
Description = Remote Desktop VNC service
After = syslog.target network.target

[Service]
Type = forking
WorkingDirectory = / home / Hitesh
User = Hitesh
The group = Hitesh

ExecStartPre = / bin / sh -c & # 39; / usr / bin / vncserver -kill% i> / dev / null 2> & 1 || : & # 39;
ExecStart = / usr / bin / vncserver -autokill% i
ExecStop = / usr / bin / vncserver -kill% i

[Install]
WantedBy = multi-user.target

Save and close the file when you are done. Then reload the system daemon with the following command:

  systemctl daemon-reload 

Then start the VNC service on display 1 and enable it to restart after system startup with the following command:

  systemctl start [email protected]: 1.service 
systemctl enable [email protected]: 1.service

You can now check the status of the VNC service with the following command:

  systemctl status [email protected]: 1.service 

You should get the following output: [19659041]? [email protected]: 1.service – Remote Desktop VNC Service
Loaded: loaded (/ etc / systemd / system / [email protected]; disabled; vendor setting: disabled)
Active: active (running) since Fri 2020-03-06 03:45:50 EST; 45s ago
Process: 2196 ExecStart = / usr / bin / vncserver-autocill: 1 (code = terminated, status = 0 / SUCCESS)
Process: 2190 ExecStartPre = / bin / sh -c / usr / bin / vncserver -kill: 1> / dev / null 2> & 1 || : (code = terminated, status = 0 / SUCCESS)
Details: 180 (limit: 12537)
Memory: 347.3M
CGroup: /system.slice/system-vncserver.slice/strong19459061??:1.service
?? 2203 / usr / bin / Xvnc: 1 -auth /home/hitesh/.Xauthority -desktop centos8: 1 (hitesh) -fp directory: /etc/X11/fontpath.d -geometry 1024>
?? 2210 sh -c (/home/hitesh/.vnc/xstartup; / usr / bin / vncserver -kill: 1) >> & # 39; /home/hitesh/.vnc/centos8: 1.log & # 39; 2> & 1 &
?? 2211 / bin / sh /home/hitesh/.vnc/xstartup
?? 2212 / usr / libexec / gnome-session-binary
?? 2221 dbus launch –sh-syntax – exit-with-session
?? 2222 / usr / bin / dbus-daemon –syslog –ork – print-pid 6 – print address 8 – session
?? 2230 / usr / bin / ssh-agent / etc / X11 / xinit / Xclients
?? 2246 / usr / libexec / at-spi-bus-starcher
?? 2251 / usr / bin / dbus-daemon –config-file = / usr / share / default / at-spi2 / accessibility.conf – nofork – print-address 3
?? 2253 / usr / libexec / at-spi2-registryd – use-gnome session
?? 2257 / usr / libexec / gvfsd
?? 2264 / usr / libexec / gvfsd-fuse /home/hitesh/.gvfs -f -o big_writes
?? 2292 / usr / bin / gnome-keyring-daemon – start – components = secrets
?? 2336 / usr / libexec / gsd-power

The VNC server has now started and is listening on port 5901. You can check it with the following command:

  netstat - tunlp | grep 5901 

You should get the following output:

  tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 2203 / Xvnc
tcp6 0 0 ::: 5901 ::: * LISTEN 2203 / Xvnc

Access VNC Server

VNC server is now installed and configured, it is time to access your VNC server from the remote computer.

Open the VNC Viewer application on the Windows / Linux machine and enter your VNC server address as shown below:

Your-server-ip: 5901

 Connect to VNC- server Ads

Click the Continue button. The following screen appears:

 Authenticate with username and password

Enter your VNC password and click the OK button. When connected, you should see your CentOS desktop on the following screen:

 Remote Desktop via VNC

Conclusion

Congratulations! You have successfully installed and configured the VNC server on CentOS 8. I hope this will help you manage remote computers easily over the network.

  Hitesh Jethva

About Hitesh Jethva

Over 8 years experience as a Linux system administrator. My skills include deep knowledge of Redhat / Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, octopus proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud , Postfix Mail Server, Security etc.


Source link