Wednesday, June 10, 2009

x11vnc on CentOS5 with GDM

Setting up x11vnc to allow remote login and control of the physical console on a CentOS5 system is easy.

Install x11vnc (e.g. yum install x11vnc)


Create a GDM init script for display :0 (or whatever display you want to connect to). The default init script is /etc/gdm/Init/Default. You can copy this to a file named for the display you are using. On my system this is ':0'.
cp /etc/gdm/Init/Default /etc/gdm/Init/:0
Edit the new init script, adding the following down at the bottom, just before the exit:

x11vnc -bg -o /tmp/x11vnc.log -reopen -forever

Note: I had "-auth /var/gdm/:0.Xauth" option until Karl (see comments) suggested it wasn't necessary - it works fine without it. The -auth option isn't required in this case because the XAUTHORITY environment variable is already set when x11vnc is executed. If running x11vnc in some other context, it would be necessary to either set the XAUTHORITY environment variable or use the -auth option.

The -bg option causes x11vnc to go to background instead of staying in the foreground until terminated. This allows GDM to carry on to do its thing.

The -0 option specifies the path of a logfile.

The -reopen option tells x11vnc to reconnect to the X server if the connection is broken, which it is after GDM completes login because the initial X server is terminated after login and a new X server is started as the logged in user.

The -forever option tells x11vnc to continue running after termination of a VNC session. With this option it is possible to disconnect and then reconnect.



For details of GDM see http://library.gnome.org/admin/gdm/2.16/configuration.html.en.

2 comments:

Unknown said...

Since you are using the gdm startup script, you shouldn't need the x11vnc '-auth' argument. Try it without it.

http://www.karlrunge.com/x11vnc/faq.html#faq-display-manager

Ian said...

Thanks Karl. I removed '-auth' as you suggested and it works fine.

Labels