Install the desktop environment that we will use:
yum groupinstall Desktop -y

Install the TigerVNC server used for VNC access and a required package:
yum install tigervnc-server xorg-x11-fonts-Type1 -y

Enable VNC server at boot:
chkconfig vncserver on

Create a VNC password for your logged in user:
vncpasswd

Now edit the /etc/sysconfig/vncservers file and add the following to the end:
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1400x700"

Make sure to change "1:root" to "1:<user>", changing the user to the user account you with to use with VNC. Also change the resolution to the dimensions you like then save the file.

Now add proper iptables firewall rules to allow VNC access remotely:
iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6001:6003 -j ACCEPT
service iptables save
service iptables restart

Now restart the VNC server then kill the active session so we can make a config change:
service vncserver restart
vncserver -kill :1

Now edit the xstartup file inside the .vnc directory of your users home directory.
nano .vnc/xstartup

Comment out the last line then set to execute gnome by adding this line:
#twm &
exec gnome-session &

Now save the file and exit, then restart the VNC server.
service vncserver restart

You should now be able to connect using a VNC client of choice on a remote computer. I recommend using RealVNC Client. Connect to your VNC at <server_ip>:1, 1 being the port.

Was this answer helpful? 4 Users Found This Useful (642 Votes)