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