HomePage :: TechnicalProjects :: VNCSetupTips

VNC Setup Tips

Configuring the server

NOTE: This section was originally researched and written by Scott Manzella


Static session numbers

From the realvnc unix vncserver docs

 vncserver can be run with no options at all. In this case it will choose the
 first available display number (usually :1), start Xvnc as that display, and
 run a couple of basic applications to get you started. You can also specify
 the display number, in which case it will use that number if it is available
 and exit if not, eg: 


 vncserver :13 

What this means is that we can designate a port for $user's vnc client that will never change, if we script it right.

Shellcode:

 #!/bin/bash
 # Copyright 2004 by Joey Kelly, http://joeykelly.net
 # This script is licensed under the GPL.
 #
 # This script is for the user to run to start a vnc session
 # Hopefully this will eliminate the problem of getting calls whenever
 # the process dies.
 #
 # here we set the port number we want to run on (vnc's real port = 5900 + $USERVNCPORT increment)
 USERVNCPORT=10     # arbitrary number, must be unique for each user
 #
 # NOTE:
 # if we want to kill the user's existing session, we would do:
 # vncserver -kill :$USERVNCPORT
 #
 # we need to kill off the old pidfiles
 # use rm -f so redhate doesn't complain with a prompt
 rm -f /tmp/.X11-unix/X$USERVNCPORT
 rm -f /tmp/.X$USERVNCPORT-lock
 #
 # now we start the vnc daemon
 vncserver :$USERVNCPORT &
 echo VNC server restarted. Please log in to VNC as normal.n
 # sometimes the terminal will hang…
 sleep 3
 echo Please press RETURN.