Building a Networking Virtual Lab part 2: Install VNC with XFCE on CentOS 7

Introduction

This is part two of Building a Networking Virtual Lab. VNC can be used to manage your Hypervisor via the Virtual Machine Manager GUI.

Step 1 Install VNC/XFCE CentOS packages

yum install epel-release –y
yum groupinstall xfce -y
yum install tigervnc-server -y
yum -y groupinstall X11 -y

Step 2 Setup VNC password for user

Login as your kvmuser. You can use any username for this.
su - kvmuser
Set a VNC password for your user.
vncserver
Exit to move back to the root user.
exit

Backup the xstatup file.
mv /home/kvmuser/.vnc/xstartup /home/kvmuser/.vnc/xstartup.org
create a new xstartup file.
vi /home/kvmuser/.vnc/xstartup

#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &

Fix owner/permissions on the new file.
chown kvmuser:kvmuser /home/kvmuser/.vnc/xstartup
chmod 755 /home/kvmuser/.vnc/xstartup

Copy the sample VNC service.
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

Edit the following lines in the file to look like the below.
vi /etc/systemd/system/vncserver@:1.service

#User=<USER>
ExecStart=/sbin/runuser -l kvmuser -c "/usr/bin/vncserver %i"
PIDFile=/home/kvmuser/.vnc/%H%i.pid

Step 3 Start VNC server

Permit the VNC service on the firewall and reload the firewall service.
firewall-cmd --permanent --zone=public --add-service vnc-server
firewall-cmd --reload

As we have made changes to the systemctl we need to reload the daemon.
systemctl daemon-reload

Start the vncserver service and set to start at boot.
systemctl enable vncserver@:1 && systemctl start vncserver@:1

Step 4 Start vnc server

Connect to the hypervisor via VNC to use Virtial Machine Manager.

vnc

Links

Part1
Part3