linux setup notes
Compiling and running VNC in Linuxby T.J. Nelson |
NC is a remote control application that sends the display, mouse, and keystrokes to a remote computer. (Not all keystrokes are transmitted—if you type Ctrl-Alt-Delete, for instance, it reboots your local PC instead of the remote one.) It's particularly useful in communicating between Linux and Windows machines.
This document describes how to set up Tight VNC 1.3.9 on a Linux server.
There are several different kinds of vnc out there with different ways of configuring them. I prefer to compile it myself, so I can use the same one on both newer and older computers.
Some versions of vnc use a file in /etc/sysconfig/vncservers
.
This has the advantage of only needing to start a single copy of Xvnc, which
is running as root. The vncservers file looks like this:
VNCSERVERS="1:bruce 2:lance 3:steve"
VNCSERVERARGS[1]="-geometry 1920x1080"
VNCSERVERARGS[2]="-geometry 800x600"
Other versions ignore this file. For these versions, each user starts a separate copy of Xvnc and leaves it running continuously. This may be a little safer, but is less scalable. Typically this second scheme would be used if all your Windows users log in on the same shared account. The second version is described here.
Xvnc is started using the vncserver
, which is a script that needs
to be edited.
vncpasswd
to create the ~/.vnc directory and
default startup files for that user.
/home/bruce/.vnc/xstartup
. This file
is comparable to the ~/.xinitrc file for X11. The last line is their window manager.
My xstartup file looks like this:
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
/usr/bin/urxvt -geometry 100x35+100+100&
/usr/bin/urxvt -geometry 100x35+100+200&
/usr/bin/wmcalclock&
/usr/local/bin/e16
#$fontPath = "unix/:7100";
$fontPath = "/usr/share/fonts/,/usr/share/fonts/misc,/usr/share/fonts/100dpi/,/usr/share/fonts/75dpi/";
su bruce; vncserver :1
su lance; vncserver :2
su steve; vncserver :3
They will be logged in as the person who started the vncserver, so if you're using this
type of vnc, you need to be careful not to start vncserver as root.
This procedure might seem strange since you can't connect to X11 using vncviewer
(e.g., by typing vncviewer localhost:0
).
VNC is not really an X server; they use entirely different protocols. It is only
sending a copy of the display.
X11 doesn't even have to be running in order to use Xvnc, so if the server is on a
text-mode command line Xvnc still gives you a graphical desktop. But X11 has to be
installed, and of course the files you include in your xstartup
must
exist. So you could use it as a cheap KVM switch if you want. With a fast enough
network, there's no reason not to.
vncviewer server.domain.com:1
server.domain.com:1
. vncviewer 192.168.100.1:1
vncserver -kill :1
. This kills the remote for one
single user.
-interface your-ip-address
. This is an essential feature: if you have
a public and a private interface, you want to block the public one to avoid getting
scanned by IT or by outsiders. IT will accuse you of running a web server, which is
not a good thing to happen in a corporate environment, so it's best to turn off or
block this function.
hosts.deny
.
vncviewer
. In
Linux, you can specify the user with the -user username
option. In Windows,
there is no way to specify the username as far as I can tell. This means your users must
have the same username on the server as on their Windows PCs.
I'm a big fan of this program. It eliminates the expense and hassle of trying to get an X11 running on a Windows machine. We use vnc on all our HPLC instruments, so we can watch the data from our desk as it appears. We can start a new sample or stop the machine remotely if a problem occurs without having to run down the hall trying to get through all those damn security doors.
When you run it in Windows, it even puts anything you select into the clipboard of the local PC, so you don't even have to transfer files from one PC to another.