Use VNC on an existing X display

VNC can be incredibly useful, particularly in a work environment where a troubled coworker could be in an entirely separate subdivision of the building. Mac OS X's proprietary implementation of VNC, known as Screen Sharing, will allow control of whoever is logged in at the moment, while under Linux starting a VNC server will create an entirely new X session independent of anyone already using the machine.

In order to use VNC on Linux in the same way as Screen Sharing, we can use a small VNC server called x11vnc. This link is a standard tarball; there may also be a binary distribution available at the x11vnc website.

To start the VNC server, use:
x11vnc -rfbauth ~/.vnc/passwd -display :0 -auth guess

If you have used VNC before, ~/.vnc/passwd will already exist. If not, you can use vncpasswd to generate one.

The auth switch will depend on your display manager. If you are using xinit, -auth guess should be able to detect the current session cookie, but if you are using GDM you will have to provide it manually.

If you are using xinit and x11vnc cannot detect the cookie, running ps auxw | grep serverauth will return something similar to
xinit /etc/X11/xinit/xinitrc -- /usr/bin/X :0 -auth /home/drsavoye/.serverauth.3033
/home/drsavoye/.serverauth.3033 will replace the guess parameter.

If you are using GDM, the cookie can be found by running ps auxw | grep cookie, which will return
/usr/bin/Xorg :0 -br -verbose -auth /var/run/gdm/auth-cookie-XX756E9U-for-gdm -nolisten tcp
/var/run/gdm/auth-cookie-XX756E9U-for-gdm will replace the guess parameter.

Now, on the client side, you can use whichever VNC viewer you choose.

No comments:

Post a Comment