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 example.home-computer.com
  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.

No comments:

Post a Comment