Copyright 1999-2000 WiSEFreeBSD, [-WiSE-]
Setting Up and using the VNC Viewer and Server
1 What is VNC
2 Setting Up The Server on FreeBSD
3 Setting Up The Server on Windows
4 Using the FreeBSD viewer
5 Using the Windows viewer
6 Using a web browser as a viewer
7 Configuring XDM for VNC
8 Configuring Inetd for VNC
VNC is shoret for Virtual Network Computing. It allows you to remotely view
your X desktop on another machine with a minimal of setup. I can also allow you
to view a windows desktop on a FreeBSD machine. It does not require the correct
setup of XDM, and it also allows you to run X on a machine that can't display
it, for viewing on another machine.
Like most unix style applications, the VNC package consists of both a server
and a client. Install both of these from the ports collection
# make install
>> vnc-3.3.3r2_unixsrc.tgz doesn't seem to exist in /usr/ports/distfiles/.
>> Attempting to fetch from http://www.uk.research.att.com/vnc/dist/.
Receiving vnc-3.3.3r2_unixsrc.tgz (2072772 bytes): 100%
[ ... configure and build process ... ]
===> Registering installation for vnc-3.3.3r2
At this point, the VNC server and viewer should be installed. To Set up the
viewer, we must first set a session password. This is user specific, so you
will want to log in as that user first.
password : [Password]
[/home/testuser]$ mkdir .vnc
Password: [session password]
Verify: [session password]
Then, we need to make a xstarup script. This is a SH style script that will
set up X for us under vnc.
[/home/testuser]$ cat .vnc/xstartup
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
That is my sample xstartup. Customize yours as you need to. The next step is
to start the server. We will start it with a color depth of 24bit, and a screen
size of 1152x864 :
[/home/testuser]$ vncserver -depth 24 -geometry 1152x864
New 'X' desktop is hostname.domain.com:1
Starting applications specified in /home/testuser/.vnc/xstartup
Log file is /home/testuser/.vnc/hostname.domain.com:1.log
It is all set to connect to now. To kill the server, do :
[/home/testuser]$ vncserver -kill :1
Killing Xvnc process ID #####
Setting up a server under windows is also pretty simple. First, retrieve the
Win32 package from http://www.uk.research.att.com/vnc/download.html
Extract it, and run setup from the winvnc folder. Run the WinVNC application
that is shown. The options should look very familiar to those that you set up
in the FreeBSD server.
To use the FreeBSD viewer, you must first be in a X session. Under an Xterm :
[/home/testuser]$ vncviewer hostname.domain.com:1
VNC server supports protocol version 3.3 (viewer 3.3)
Password: [session password]
VNC authentication succeeded
Desktop name "hostname"
Connected to VNC server, using protocol version 3.3
VNC server default format:
16 bits per pixel.
Least significant byte first in each pixel.
True colour: max red 31 green 63 blue 31, shift red 11 green 5 blue 0
Using default colormap which is TrueColor. Pixel format:
8 bits per pixel.
True colour: max red 7 green 7 blue 3, shift red 0 green 3 blue 6
The windows viewer is nearly as simple. It installs with the server, or without
first installing the server, it is availible in the vncviewer directory of the
distribution. Specify the host as hostname.domain.com:displynumber. Enter the
same session password as before.
A note on both viewers :
When you exit the viewer, the server does not die. Nor do the applications that
are running under the VNC instance. So, if for whatever reason you connection dies,
you won't lose anything.
To use a webserver as a viewer, point the webbrowser at
where XX is the display number. In our example is is 01. Keep in mind that the
display refresh in this mode is considerably slower than the actual viewer.
I have been told that XDM can be configured to use VNC as well. It is a rather
complex setup, and I have found it to be relativly unstable. But, here goes.
First, edit your /etc/X11/xdm/xdm-config
Add the lines :
And Comment out the line :
Then, edit /etc/X11/xdm/Xservers and add the line (yes, all one line):
:12 local /usr/X11R6/bin/Xvnc :12 -broadcast -ac -dontdisconnect -geomerty
1152x864 -auth /etc/X11/xdm/xauthvnc
Also, edit /etc/X11/xdm/Xaccess and uncomment the line :
* #any host can get a login window
At this point, restart xdm, and you should have a login window waiting for you
Further, it is possible to run Xvnc off of inetd. I have this working as
well, and it appears to run a login window. However, XDM must be running on
a local display for this to work. Or for that matter, it seems for inetd to
work at all. Anyway, here we go.
Edit /etc/services and add :
Then, edit /etc/inetd.conf and add (as one line, split for readability :
vnc stream tcp nowait root /usr/X11R6/bin/Xvnc
Xvnc -inetd -broadcast -once -geometry 1152x864 -depth 24
Note that there may be security implication to running it as root. I don't
know. Connect to hostname.domain.com:50. It will spawn a session for
each time you connect.
Just a note, you will only be able to login properly if you can login with
a usable .xsession and such under xdm. When using XDM, you may want to
remove the setuid bit on the xserver. Dunno what the security implications
of this might be though. Thats how I got it to work though.
Thanks to the VNC people, Andre Moreira (inetd stuff) and misc mailing lists
for the abundance of XDM help.