Tuesday, August 2, 2011

Ubuntu Remote Desktop


I recently had the need to get reliable remote access to the desktop of an Ubuntu 10.04 install. There are many ways to enable remote access to your X11 desktop in Ubuntu, each with different trade-offs. Here are three (all VNC-based) that I recently looked into:

  • Built-in - System > Preferences > Remote Desktop. Easy, but only works if you're already logged in locally. i.e. after a system restart you can't connect remotely until you login locally again. Common work-around for that: use auto-login (yuck).
  • Xvnc - Create a new X display only viewable via VNC. i.e. the remote user has its own desktop unrelated to what is seen on the monitor if a local user logs in.
  • x11vnc - Serve up what is being shown on the local monitor (i.e. a "real" X display) over VNC. Similar to the built-in solution, but without the "must be logged in" restriction.

My requirements were:

  • Must be able to login remotely after a system restart
  • Must be able to plug in a monitor and see what the remote user sees/last saw (i.e. be able to fix things in the GUI if I break them remotely)

What I Actually Did

Used x11vnc and started right after gdm starts. Here are all the steps:

  1. sudo apt-get install x11vnc
  2. Create a VNC password in a stable location:
    sudo mkdir -p /etc/x11vnc
    x11vnc -storepasswd  /etc/x11vnc/passwd
  3. Add the following to /etc/gdm/Init/Default, right before the exit 0 at the end of the script:
    /usr/bin/x11vnc -safer -allow,192.168.1. -o /var/log/x11vnc.log -xkb -bg -forever -rfbauth /etc/x11vnc/passwd -display :0
  4. Reboot, or just restart gdm (sudo restart gdm).
  5. Should now be able to connect to port 5901 with a VNC client (I used TightVNC).

If things don't work, check /var/log/x11vnc.log -- there's usually a lot of detail in there explaining exactly what is going on.

Clusterfuck Alert

Ubuntu (at least in 10.04) has a crazy issue where X won't start if a monitor is not plugged in when the system restarts. I don't know -- and don't want to know -- why, but there are work-arounds. I'll link to a few below, but the gist of it is to not use the fancy NVidia or ATI drivers, but instead just use the VESA driver. If you're going to have a monitor attached all the time, this is not an issue.


No comments:

Post a Comment