CentOS 7 – Configure TigerVNC Server

I don’t normally need a remote GUI desktop on my linux VMs but I wanted to test Vagrant and easily monitor VirtualBox status with multiple terminals open at the same time.  So after a few Google searches to determine why my remote connection is failing to start I’m boiling it down to the steps below.  These steps assume your remote user name will match a current local user name as seen in step 5.

  1. Launch VM console and login with account that has sudoer capability
  2. sudo yum groupinstall “GNOME Desktop” –y
  3. sudo yum install tigervnc-server –y
  4. sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
  5. sudo sed –i “s/<USER>/yourcurrentusername/g” /etc/systemd/system/vncserver@:1.service
  6. sudo echo X-GNOME-Autostart-enabled=false >> /etc/xdg/autostart/gnome-software-service.desktop
    – Kills prompt for network proxy used for downloading packages
  7. sudo systemctl set-default graphical.target
  8. sudo systemctl daemon-reload
  9. sudo systemctl enable vncservice@:1.service
  10. sudo firewall-cmd –permanent –zone=public –add-service=vnc-server
    – sudo firewall-cmd –get-default-zone to verify zone is set to public
  11. sudo firewall-cmd –reload
  12. su yourcurrentusername
  13. vncpasswd
    – set a password that will be used for initial VNC connection
  14. netstat –at
    – verify port 5901 is listening


Fix broken VNC service
Login as remote user via ssh and run vncserver to get details on the problem
sudo systemctl stop vncservice@:1.service
find /tmp/.X* -user $USER –exec rm –f {} \; 2> /dev/null
sudo systemctl start vncservice@:1.service
retry connection

Update 2/28/2017
I got an itch to automate these steps and it is working well enough in my lab environment.  Call the script using bash setupTigerVNC.sh username1 username2 username3.  The usernameX should already be a local user on the system.