Saturday, April 21, 2012

Remote GDM3 Login with VNC

I usually leave my computer at home turned on, logged in to the graphical desktop, with a VNC server running, to allow remote access to the desktop with a VNC viewer.

A few days ago, while waiting for code to compile, I logged in to my computer from work, and performed a long overdue package upgrade, which required a reboot to complete. This left me logged out of the desktop, with the GDM3 greeter waiting for someone to log in, but no VNC server to allow remote access to it.

Here's how to run a VNC server and start the desktop, in this situation:
  1. connect to the remote machine with ssh, forwarding the default VNC port (this is the usual way I access my home PC):
    # ssh -L 5901:localhost:5900
  2. run the following command as root to detect the path to the X authority file:
    $ ps ax | grep auth
     1398 tty7     Ss+    4:30 /usr/bin/Xorg :0 -br -verbose -novtswitch -auth /var/run/gdm3/auth-for-Debian-gdm-e7ERxa/database -nolisten tcp vt7
     5053 pts/5    S+     0:00 grep --color=auto auth
  3. launch a VNC server (as root) that allows access to your real X11 display, using the path to the X authority file (I use x11vnc):
    $ x11vnc -xkb -ncache 0 --forever -localhost -display :0 -auth /var/run/gdm3/auth-for-Debian-gdm-e7ERxa/database
  4. back on the local machine - connect to the remote machine with a VNC viewer (I use realvnc here):
    # vncviewer -FullScreen -LowColourLevel 2 -PreferredEncoding ZRLE localhost:1
    you should now see the remote GDM greeter and be able to login to your desktop.


  1. I have executed "x11vnc -forever", but now I want to edit the way it starts... I can not for the life of me figure out where it is getting started. I think I am using gdm 2.30.4 in SciLinux 6.4. Do you know how I can edit the start-up options of x11vnc?

    1. Here's a quote from the x11vnc manpage that seems relevant. Hope this helps.

      Config file support: if the file $HOME/.x11vncrc exists then each line in it is treated as a single command line option. Disable with -norc. For each option name, the leading character "-" is not required. E.g. a line that is either "forever" or "-forever" may be used and are equivalent. Likewise "wait 100" or "-wait 100" are acceptable and equivalent lines. The "#" character comments out to the end of the line in the usual way (backslash it for a literal). Leading and trailing whitespace is trimmed off. Lines may be continued with a "\" as the last character of a line (it becomes a space character).


Note: Only a member of this blog may post a comment.