VNC on an Ubuntu VPS

VNC viewer

Although I do most of my server configuration and administration from the command line, occasionally it’s helpful to have access to GUI applications.  Since the machines are remote, and tightly constrained in terms of memory, it makes sense to use the lightest option available.  My current setup use the tightvnc VNC server in conjunction with the fluxbox window manager.  It’s not very pretty, but it does work.  Using SSH tunneling, it’s also quite secure.

Installation instructions:

1) Install tightvnc and fluxbox.

$ sudo apt-get install tightvncserver fluxbox xterm

2) Set a password for VNC (say no to view-only).

$ tightvncpasswd

3) Tell the VNC server to use fluxbox by putting the following in ~/.vnc/xstartup:

#!/bin/sh
/usr/bin/fluxbox

Make xstartup executable:

$ chmod +x ~/.vnc/xstartup

4) Update the fluxbox menu.

$ mkdir -p ~/.fluxbox

Create ~/.fluxbox/menu with the following text:

[begin] (fluxbox)
[include] (/etc/X11/fluxbox/fluxbox-menu)
[end]

5) Launch the VNC server.

$ tightvncserver -nolisten tcp -localhost :1

6) On the client side, tunnel the VNC port using ssh (port 5901 if display 1 was used, 590X for display X):

$ ssh -L 5901:localhost:5901 XXX.XXX.XXX.XXX

7) Open a VNC viewer on the client and connect to localhost, display 1 (aka port 5901)

8) When finished, you can terminate tightvnc on the server with the following:

$ tightvncserver -kill :1

Net result: a secure, remotely accessible GUI running directly on the server, but using minimal memory and bandwidth.

Comments are closed.