Short Tip: access a running X session via x11vnc

cube-with-matrix
There are thousands of ways to access a running Linux machine. In case you need for whatever reason remote access to a full session, one easy way is x11vnc. Given that the user is already logged into X, access the machine via ssh, log in as the user who opened the X session, and enter:

x11vnc -display :0

Now you can access the machine with a vnc viewer, for example with 192.168.123.45:0. Beware however that this configuration has no encryption via network – and no vnc password at all!

In case you need to access a running login manager (where no user is logged in yet) first get the authentication file of the running X and hand it over to x11vnc (as root):

host:~# ps x|grep X
 1425 tty8     Ss+    0:01 /usr/bin/X -br :0 vt8 -auth /var/run/xauth/A:0-1EkR5c
host:~# x11vnc -display :0 -auth /var/run/xauth/A:0-1EkR5c

A good client to connect to the running vnc session is KDE’s krdc.