Install VNC Server and Desktop on CENTOS6 /RHEL 6


1. Run

yum update -y


yum install nano -y


2. Then install below

yum groupinstall Desktop -y



3. Once the install is completed lets move forward to install the VNC server and an additional supporting packages required.

yum install tigervnc-server xorg-x11-fonts-Type1 -y



4. Set the VNC server to auto start after every reboot.

chkconfig vncserver on



5. Now set a VNC password with the use vncpasswd utility for authentication to use when connecting. Run the following command from respective user(s) which will be allowed to connect.

vncpasswd
Password:
verify:
In above command it will ask to set a password, enter the password that you want to use and press enter, then re-enter to .


6. Now edit the VNC server configuration now.

vi /etc/sysconfig/vncservers

After you've opened up the vncserver configuration lets navigate to the bottom of the file and add the following lines:


VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1024x600"

Save the file after making these changes.


7. Restart the VNC service now to allow the changes to take affect.

service vncserver restart



8. Now kill the active VNC session so we can edit the xstartup file for the user that it's running under.

vncserver -kill :1



9. Edit the xstartup file now by running:

vi .vnc/xstartup



10. At the bottom line of the file you'll see

twm &

Comment it with # and add exec gnome-session & :
#twm &
exec gnome-session &



11. Restart the VNC server now.

service vncserver restart



12. Use below command

 
 ssh -L 5901:127.0.0.1:5901 -C -N -l OS-USER 



13. Disable all the Firewalls or allow VNC connection in them one by one.


14. Now Install RealVNC on your desktop and enter :5901, it will ask for password, enter the password you set in step 5.


15. You are connected, in case it does not connecte restart the vnc server and it will connect.