Saturday 26 October 2013

Setting up VNCServer on CentOS

    VNCServer is used to give control of the screen to remote clients. VNCServer allows to share different desktop perspective to different client using port numbers. In this session I will explain to setup VNCServer on CentOS 6.4 desktop machine.




    In order to install vncserver open System -> Administration -> Add/Remove Software as shown below. 



    
     You may be given a warning if you are a root user, select continue as shown below.





    It will open up Add/Remove Software dialog box. Enter vnc in the search box and click Find. From the list of available packages select "A TigerVNC server", select checkbox next to it, Apply button on right below with enable. Click it to install the server, if prompted for any dependent package install that as well. See figure below for details.


Alternatively you can install the vncserver using method mentioned for Ubuntu 12.04 here

After VNCServer is installed on the system, open a terminal and execute vncserver command as shown below.
[arslan@localhost~]# vncserver
New 'arslan.localdomain:1 (arslan)' desktop is arslan.localdomain:1
Starting applications specified in /arslan/.vnc/xstartup
Log file is /arslan/.vnc/arslan.localdomain:1.log
[arslan@localhost ~]# 


    In above command display is shown to be 1 , it means port 5901, if you execute another vncserver command then another display 2 will open at port 5902, similarly multiple displays can be opened using vncserver.


    In order to specify vnc password execute vncpasswd command as shown below.
[arslan@localhost ~]# vncpasswd
Password:
Verify:
[arslan@localhost ~]# 





    In order for VNC clients to be allowed to connect to VNCServer on a specific port we need to add this port in list of trusted connections. This is not needed in some other distributions of linux like ubuntu, but its a must for CentOS, otherwise clients won't be able to connect to the server. In order to accomplish this open System -> Administration -> Firewall as shown below.



    In FireWall Configuration dialog open Other Ports tab and click Add button. It will open up Port and Protocol dialog. Add the ports on which vncserver sessions are currently running. You can either specify individual port or range of ports as shown below.

Individual port



Range of ports

    After adding ports click Apply in Firwall Configuration dialog to override existing firewall configuration add add vncserver ports in list of trusted ports.

    Now on the client machine install a suitable VNC Viewer like Real VNC Viewer and connect to the remote vnc server. Kindly note that you can either specify port or desktop console id which was generated by vncserver command. Both options are shown below.

Connection to VNC Server using port number

Connecting to VNC Server using desktop id




No comments:

Post a Comment