Vncserver is a remote display daemon that allows users several remote functionalities including:
- Virtual (headless) and fully parallel X sessions that run in the background (i.e. not on the physical monitor but virtually) on a machine. All applications running under the server may continue to run, even when the user disconnects.
- Direct control of the local X session(s) (i.e. X running on the physical monitor).
Machine: Vmware Centos 7 Guest IP = 192.168.254.133
Install vnc server on CentOS 7
Add vnc user:
[[email protected] ~]# add pirat9
Set password for pirat9 user:
[[email protected] ~]# passwd pirat9
Lets Start:
[[email protected] ~]# yum check-update [[email protected] ~]# yum groupinstall "GNOME Desktop" [[email protected] ~]# unlink /etc/systemd/system/default.target [[email protected] ~]# ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target [[email protected] ~]# reboot
After reboot, you will get Centos 7 desktop.
Now start installing VNC packages.
Step 1 » install VNC package.
[[email protected] ~]# yum install tigervnc-server xorg-x11-fonts-Type1 -y
Step 2 » Create a file ‘[email protected]:1.service’ in /etc/systemd/system/ directory by copying example config file /lib/systemd/system/[email protected]
[[email protected] ~]# cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:1.service
Step 3 » Now open /etc/systemd/system/[email protected]:1.service file and replace with your username .
Find these lines:
ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i" PIDFile=/home/<USER>/.vnc/%H%i.pid
Replace (username as pirat9):
ExecStart=/sbin/runuser -l pirat9 -c "/usr/bin/vncserver %i" PIDFile=/home/pirat9/.vnc/%H%i.pid
Or root user:
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i" PIDFile=/root/.vnc/%H%i.pid
Step 4 » Reload systemd for changes.
[[email protected] ~]# systemctl daemon-reload
Step 5 » Create VNC password for the user .
[[email protected] ~]# vncpasswd
Step 6 » Enable and start the service using the below commands.
Enable service at startup ( Permanent ).
[[email protected] ~]# systemctl enable [email protected]:1.service Start the service . [[email protected] ~]# systemctl start [email protected]:1.service
Step 7 » Allow VNC service in firewall.
[[email protected] ~]# firewall-cmd --permanent --add-service vnc-server [[email protected] ~]# systemctl restart firewalld.service
Now you can able to connect VNC server using IP and Port.
Done!