Remote access to Linux display

VNC server on Linux normally just lets you log in with a new session, but it is also possible to connect to an existing display and use it remotely.

1. SSH with port forwarding

$ ssh my.hostname -L 5900:

2. Find xauthority file

$ ps wwwaux | grep auth
root      3360  0.0  0.3 309556 50380 tty7     Ssl+ Mar20   6:33 /usr/bin/Xorg :0 -background none -verbose -auth /run/gdm/auth-for-gdm-lXSVZp/database -seat seat0 -nolisten tcp vt7

The -auth part is what matters (in the case above, /run/gdm/auth-for-gdm-lXSVZp/database)

3. Start x11vnc

I have to use sudo because my user doesn’t have permission to read the auth file – YMMV.

$ sudo x11vnc -auth /path/to/auth/file -display unix/:0

4. Connect using a VNC client
The address will be, which is being forwarded to the remote host by SSH.  If x11vnc picks a port other than 5900 you’ll need to disconnect and modify the SSH port forwarding