How to set-up VNC without a window manager

It’s a server, who needs GUI anway?

Some good utilities require a graphical display to be used. One good example is aptitude, which lets you browse apt packages, or jconsole, a java process monitoring dashboard.

It’s UNIX man, just use X

The problem is, if that application updates the screen too much and you’re over a bad connection, X isn’t really effective in sending screen updates over the wire. Even with ssh compression and X authentication disabled, it can be pretty slow.

Gotcha. Any better solutions?

Enter VNC. VNC runs an X server in the remote server, and allows remote hosts to connect to it via a VNC viewer application (I use Chicken of the VNC for Mac). It’s protocol is very much optimized for low bandwidth connections, resorting to lower color depth and region-based updates to improve on sending data to the clients.

But VNC requires a window manager, and that’s heavy!

Sure, running a window manager in a UNIX box is a waste of precious memory and other resources, that could be better used by the server’s main application, be it a database, web server, application server, etc. But VNC doesn’t need one!

How-to

  1. Install a VNC server in your server. I’m using RHEL5, so I used yum: yum install tightvnc-server-1.3.9-3.el5.rf.x86_64
  2. Connect to the remote server using ssh. Set up a tunnel on port 5900 (VNC for display :0): ssh user@host -L5900:localhost:5900
  3. Start a VNC server in the background using display 0: Xvnc :0 &
  4. Set your ssh session’s display to be display 0: export DISPLAY=”:0″
  5. Run your GUI application/tool. I’m using jconsole: jconsole
  6. Now on your workstation, launch your VNC Viewer, and connect to localhost
  7. Enjoy faster screen updates over the remote connection 😉
Please leave a comment if this was useful for you. I googled around for this yesterday and only recommendation I got was using xfce or some other lightweight window manager.