Wednesday, 21 September 2011

VNC server on Centos 6.0

Was trying to configure vnc on centos 6. Following are the steps which I used.

#yum install vncserver

useraccount 'tom' was already created

therefore just logged on as the user and ran the following command to set the vnc password


which creates a .vnc directory under the home directory of the user

Edit the server configuration {/etc/sysconfig/vncservers } as follows

VNCSERVERARGS[1]="-geometry 640x480"

Then restart the services:

#service vncserver start

Change the firewall settings by editing /etc/sysconfig/iptables and I had to allow the following as I had other users configured as well

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 6001 -j ACCEPT

Now I can connect from ubuntu or realvnc clents from other workstations.

But I encountered the following error when restarting the system and service

A VNC server is already running as :10

When I checked the logs, what I saw was:

Starting up the machine number 10
Cannot bind the socket to the display. Error:1 at /usr/bin/vncserver line 275.
A VNC server is already running as :10

but checking for processes running on 5910 and 5810 showed that none were listening:

[root@myserver]$ netstat -an | grep 5910
[root@myserver]$ netstat -an | grep 5810

after some searching, I finally found this link that lead me to the answer.
There was another stray process that was listening at tcp port 6010 as shown below

[root@myserver]$ /usr/sbin/lsof -i tcp:6010
sshd    19464 root    8u  IPv4 143749109       TCP localhost.localdomain:x11-ssh-offset (LISTEN)

All I had to do was kill that process 19464 and then the vncserver was able to start up correctly.
ADDENDUM I finally found out what was causing it. It was my own ssh sessions to the server with X11Forwarding enabled that were causing the conflicts. So the ultimate resolution to the problem was to add the following into the "/etc/ssh/sshd_config" file.
X11DisplayOffset 50
and restart the sshd.



1 comment: