Categories


Ubuntu TightVNC Server

This guide intends to show you how to build a headless server with tightvnc, such that you can remotely access the server’s gui using any vnc client.  I’m still working on it, so if you have any comments or questions, please feel free to let me know.

Type:

sudo apt-get install tightvncserver

Then create and edit: /etc/init.d/vncserver in your favorite text editor. Copy and base the contents between the ——, then modify the variables up top as necessary.

#!/bin/sh -e
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Default-Start: S
# Default-Stop: 0 6
### END INIT INFO

PATH="$PATH:/usr/X11R6/bin/"

# The Username:Group that will run VNC
export USER="username"
#${RUNAS}

# The display that VNC will use
DISPLAY="1"

# Color depth (between 8 and 32)
DEPTH="16"

# The Desktop geometry to use.
#GEOMETRY="x"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"

# The name that the VNC Desktop will have.
NAME="desktopname"

OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

. /lib/lsb/init-functions

case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;

stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;

restart)
echo "need to implement"
;;
esac

exit 0

Save the file and make sure the permissions are as follows:

-rwxr-xr-x 1 root root

Update your rc.d by running:

update-rc.d vncserver defaults

Reboot and you should be good to go.

— Update
I’ve been told the single / double quotes in my script don’t copy and paste properly, I’m not entirely sure what WordPress is doing to the quotes, but for whatever reason you may want to run a find / replace on them before you use the script.

On ubuntu 10.04 you have to remve the –geometry switch on the OPTIONS line