Tuesday, July 15, 2014

CentOS 7: Install VNC Server

VNC is a remote desktop protocol, commonly used for Linux systems. The remote system runs a VNC server which can then be accessed by a local VNC client. The TigerVNC server can be installed from the CentOS-7 repository with the following yum command:

# yum install tigervnc-server
After the TigerVNC server is installed, it can be started from the command line:

# vncserver
If at this point, the server is still inaccessible from a VNC client, check firewall status. Note that CentOS 7 uses the firewalld service, instead of iptables.

# service firewalld status
Assuming the firewall is running, it is likely blocking the port used by the VNC server. Try manually opening this port with the following command:

# firewall-cmd --permanent --add-port=5901/tcp
If the VNC client can connect to the server but the desktop is blank, the server is missing a desktop environment. The CentOS-7 repository includes packages for either KDE or GNOME desktop environments. KDE can be installed using the following yum command:

# yum groupinstall "KDE Plasma Workspaces"
In order for the VNC server to make use of KDE, edit ~/.vnc/xstartup to contain the following:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startkde &

Finally, kill and restart the VNC session:

# vncserver -kill :1 # vncserver
Optionally, the screen resolution of the VNC session can be set with the -geometry option:

# vncserver -geometry 1920x1080