VNC
is a protocol that is used to share the desktop with other users/computers over
the network/Internet. In order to share a desktop, VNC server must be install
and configure on the computer and VNC client must be run on the computer that
will access the shared desktop.
But some people
prefer GUI instead and for this they install Full version of Gnome on CentOS/RHEL.
Actually there is a better way and that is to install VNC. VNC provides a
lightweight virtual desktop than full blown version of Gnome.
To run the VNC
Server on CentOS/RHEL, we have to install these required packages:
[root@rhel6 ~]# yum
groupinstall Desktop
[root@rhel6 ~]# yum
install tigervnc-server
[root@rhel6 ~]# yum
install vnc
To start
VNC Server on boot
[root@rhel6 ~]#
chkconfig vncserver on
To setup
users’ VNC password:
[root@rhel6 ~]#
vncpasswd
Password: ******
Verify: ******
Edit
the /etc/sysconfig/vncservers file and add the following to
the end of the file:
[root@rhel6 ~]# vim
/etc/sysconfig/vncservers
#VNCSERVERS=”2:myusername”
#VNCSERVERARGS[2]=”-geometry 800x600” –nolisten tcp –localhost”
VNCSERVERS=”1:root” [ New Entry]
VNCSERVERARGS[1]=”-geometry 1024x600” [ New
Entry]
Restart
the VNC Server:
[root@rhel6 ~]# service
vncserver restart
Edit
the xstartup file in .vnc directory and Comment the
last line and run the Gnome:
[root@rhel6 ~]# vim
/root/.vnc/xstartup
#twm & [comment this line]
Exec gnome-session & [New Entry ]
Restart
the service:
[root@rhel6 ~]# service
vncserver restart
Now,
download VNCViewer onto our desktop computer from
which we want to access the shared desktop. Connect using ServerIP/Name:1 (:1 is for
the VNC server window), In my case it is 192.168.1.122:1.
Enter
the password that we created using the vncpasswd command
We now
have GUI access to our server.
Ability to connect for multiple users:
Create a
local user, using the following command:
Create a
password for newly created user:
Switch to
the newly created user and run vncpasswd command
for it:
Edit
the /etc/sysconfig/vncservers file:
[root@rhel6 ~]# vim
/etc/sysconfig/vncservers
Add these lines for new user:
VNCSERVERS="1:arbab
2:ali"
VNCSERVERARGS[1]="-geometry
1024x600"
VNCSERVERARGS[2]="-geometry
1024x600"
Restart the VNC service:
sudo service vncserver restart
Modify the file so it looks like this:
#twm &
exec gnome-session &
Restart the
VNC service:
Connect with newly created user using centos:2, Where centos is my server name:
Enter the
password that we created using the vncpasswd command:
ConversionConversion EmoticonEmoticon