<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html><head><!--Converted with LaTeX2HTML 2K.1beta (1.48)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others --><title>Remote LTSP access with SSHVNC applet</title>

<meta name="description" content="Remote LTSP access with SSHVNC applet">
<meta name="keywords" content="sshvnc">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="LaTeX2HTML v2K.1beta">
<meta http-equiv="Content-Style-Type" content="text/css">

<link rel="STYLESHEET" href="sshvnc.css"></head>



<body>

<p>
</p><h1 align="center">Remote LTSP access with SSHVNC applet</h1>

<p>

</p><h1><a name="SECTION00010000000000000000">
1 Introduction</a>
</h1>

<p>
Using VNC and ssh, it is possible to allow your LTSP users to access
your terminal server securely from anywhere in the world. This is
very useful for road warriors, students/teachers at home, etc. While
this can be done with ssh port forwarding and the VNC client, that
solution can be confusing for normal end users. This document will
show how that works, but will also introduce a solution using the
SSHVNC java applet from http://www.sshtools.com/. This simplifies
the process by wrapping the ssh port forwarding and VNC client into
one applet. All the user needs is a url, their username and their
password. No special knowledge or training is required. After logging
into the applet, he user will have exactly the same interface they
would have if they were sitting at one of your LTSP terminals, and
there is no special software required for the user, only an Internet
connection and a web browser with Java. The emphasis on this solution
is on ease of use for end users. I wanted a way for our remote users
to use our terminal server without knowing anything but their username
and password.

</p><p>
Because the SSHVNC applet implements ssh port forwarding, the only
port that needs to be accessible on your terminal server is the ssh
port (22). All the data to and from your terminal server is delivered
over a secure ssh connection.

</p><p>

</p><h1><a name="SECTION00020000000000000000">
2 Overview</a>
</h1>

<p>
Here are the basic components needed to implement this solution

</p><p>

</p><ul>
<li>VNC server - There are many. I use the server from http://www.tightvnc.org/
</li>
<li>Web server - Again, there are many. I use apache http://www.apache.org/
</li>
<li>ssh server - Linux distributions all come with the ssh server from
http://www.ssh.org/
</li>
<li>SSHVNC applet - This is available from http://www.sshtools.org/
</li>
</ul>
You will need to enable ssh access to your terminal server. With normal
ssh port forwarding and VNC, you can forward the ports from a gateway,
but the SSHVNC client requires that the ssh server is running on the
box you are connecting to with VNC. The applet can live on any web
server. If you already have a web server up, you can put it on that.
There is no need to set up another web server. You will configure
the applet to connect to the right ssh server. The VNC server will
be set up to start via the Internet Daemon (inetd/xinetd). This will
allow a new VNC server to be started automagically for all incoming
connections.

<p>

</p><h1><a name="SECTION00030000000000000000">
3 Getting the software</a>
</h1>

<p>

</p><h2><a name="SECTION00031000000000000000">
3.1 Getting Apache</a>
</h2>

<p>
Installation and configuration of Apache is beyond the scope of this
document. The instructions will depend on what distribution you are
using and whether you are installing a binary package or compiling
from source. There is excellent documentation on the Apache web site.

</p><p>

</p><ul>
<li>http://www.apache.org
</li>
</ul>
Once you have Apache installed, there are a few things you can do
to make it easier for your users. You might want to set up a virtual
server for the SSHVNC applet and made an index file that launches
the applet in a different window. I'll give an example below in the
SSHVNC configuration section.

<p>

</p><h2><a name="SECTION00032000000000000000">
3.2 Getting SSHVNC</a>
</h2>

<p>
The SSHVNC applet is available here

</p><p>

</p><ul>
<li>http://sourceforge.net/projects/sshtools
</li>
</ul>
There is also an SSHVNC client that can be installed locally. This
has the advantage of a seucre file transfer client, but it requires
that the user install and configure the software on their local machine.
I was going for no software install and ease of use with this setup.

<p>
Installing the applet is easy. Simply download it and extract it to
a directory that is accessible by your web server. For example, if
you downloaded it to /usr/local/src/ and your apache document root
is /usr/local/apache2/htdocs

</p><p>
</p><blockquote>
cd /usr/local/apache2/htdocs/
</blockquote>
<p>
</p><blockquote>tar -xvzf /usr/local/src/SSHVnc-0.1.3-applet-signed.tar.gz

</blockquote>
If Apache is running, you should now be able to point your browser
at your web server and the applet will download and run like so

<p>
</p><blockquote>
http://my.web.server/ssh-applet/ssh-applet.htm

</blockquote>

<p>

</p><h2><a name="SECTION00033000000000000000">
3.3 Getting sshd</a>
</h2>

<p>
Most Linux distributions come with an ssh server already. If you don't
already have one, check your distribution for the specifics on installing
one, or visit http://www.ssh.org/

</p><p>
Once you have an ssh server installed, you can verify that it is running
with

</p><p>
</p><blockquote>
ps waux | grep sshd

</blockquote>
You should see a line like this in the output

<p>
</p><blockquote>
root 934 0.0 0.0 2620 1032 ? S Mar26 0:13 /usr/sbin/sshd

</blockquote>

<p>

</p><h2><a name="SECTION00034000000000000000">
3.4 Getting the VNC server</a>
</h2>

<p>
There are many VNC servers. I use the tightVNC server because one
of their focuses is low bandwidth operation. I want the experience
to be as useful as possible for my users on slow dial up connections.

</p><p>
The tightVNC server is available here

</p><p>
</p><blockquote>
http://www.tightvnc.org/

</blockquote>
It is available in either rpm or source formats. If your distribution
supports rpm, installing it is as easy as

<p>
</p><blockquote>
rpm -ivh tightvnc-server-1.2.9-1.i386.rpm 

</blockquote>
If your distribution doesn't support rpm or you would like to compile
it locally for some reason, download the source and read the INSTALL
file.

<p>

</p><h1><a name="SECTION00040000000000000000">
4 Configuring the software</a>
</h1>

<p>
There are two major components to the configuration. They are configuring
the SSHVNC client and configuring the VNC server to use the internet
daemon. 

</p><p>

</p><h2><a name="SECTION00041000000000000000">
4.1 Configuring the VNC server</a>
</h2>

<p>
In order for a new VNC server to be spawned each time a user connects,
we need to set up the Internet Daemon (inetd/xinetd.) Suse Linux handles
starting the VNC server through inetd very well. My terminal server
is currently RedHat, so I modified the Suse configuration to fit.

</p><p>

</p><h3><a name="SECTION00041100000000000000">
4.1.1 Setting up inetd</a>
</h3>

<p>
Some distributions use inetd, some use xinetd, the extended internet
daemon. You may have to adjust this configuration depending on your
distribution. This configuration is currently running on RedHat 7.3
which uses xinetd. In order to enable a service in xinetd, you set
up a file in <i>/etc/xinetd.d</i> for that service. In this case,
we create the file <i>/etc/xinetd.d/vnc</i>

</p><p>
</p><blockquote>
# default: off 
</blockquote>
<p>
</p><blockquote># description: This serves out a VNC connection which starts at a
KDM login \ 
</blockquote>
<p>
</p><blockquote># prompt. This VNC connection has a resolution of 1024x768, 16bit
depth. 
</blockquote>
<p>
</p><blockquote>service vnc10 { 
</blockquote>
<p>
</p><blockquote>disable = no 
</blockquote>
<p>
</p><blockquote>socket_type = stream 
</blockquote>
<p>
</p><blockquote>protocol = tcp 
</blockquote>
<p>
</p><blockquote>wait = no 
</blockquote>
<p>
</p><blockquote>user = nobody 
</blockquote>
<p>
</p><blockquote># server = /usr/X11R6/bin/Xvnc 
</blockquote>
<p>
</p><blockquote>server = /usr/bin/Xvnc 
</blockquote>
<p>
</p><blockquote># server_args = :42 -inetd -once -query localhost -geometry 1024x768
-depth 16 
</blockquote>
<p>
</p><blockquote>server_args = :42 -inetd -once -query localhost -geometry 800x600
-depth 16 -fp tcp/fonts1.gouldacademy.internal:7100 
</blockquote>
<p>
</p><blockquote>type = UNLISTED 
</blockquote>
<p>
</p><blockquote># port = 5910 
</blockquote>
<p>
</p><blockquote>port = 5901
</blockquote>
<p>
</p><blockquote>}
</blockquote>
<p>
</p><blockquote>service vnchttpd10 { 
</blockquote>
<p>
</p><blockquote>disable = no 
</blockquote>
<p>
</p><blockquote>socket_type = stream 
</blockquote>
<p>
</p><blockquote>protocol = tcp 
</blockquote>
<p>
</p><blockquote>wait = no 
</blockquote>
<p>
</p><blockquote>user = nobody 
</blockquote>
<p>
</p><blockquote>server = /usr/X11R6/bin/vnc_inetd_httpd 
</blockquote>
<p>
</p><blockquote># server = /usr/bin/Xvnc 
</blockquote>
<p>
</p><blockquote>server_args = 800 600 5910 
</blockquote>
<p>
</p><blockquote># server_args = -inetd -httpport 5910 -httpd /usr/share/vnc/classes 
</blockquote>
<p>
</p><blockquote>type = UNLISTED 
</blockquote>
<p>
</p><blockquote># port = 5810 
</blockquote>
<p>
</p><blockquote>port = 5801 
</blockquote>
<p>
</p><blockquote>}

</blockquote>
Now you can restart the xinetd server with

<p>
<i>/etc/init.d/xinetd restart</i>

</p><p>
As you can see, xinetd will start a script called <i>vnc_inetd_httpd</i>
when accessed on port 5801. This script was slightly modified from
the Suse script of the same name. I'll include links to copies of
these files because the formatting here might not be great. Here it
is.

</p><p>
</p><blockquote>
#!/bin/sh </blockquote>
<p>
</p><p>
</p><blockquote>read request url httptype || exit 0 </blockquote>
<p>
</p><p>
</p><blockquote>url="${url/M/}" </blockquote>
<p>
</p><p>
</p><blockquote>httptype="${httptype/M/}"</blockquote>
<p>
</p><p>
</p><blockquote>width=$1 </blockquote>
<p>
</p><p>
</p><blockquote>height=$2 </blockquote>
<p>
</p><p>
</p><blockquote>port=$3</blockquote>
<p>
</p><p>
</p><blockquote>if [ "x$httptype" != "x"
]; then </blockquote>
<p>
</p><p>
</p><blockquote>line="x" </blockquote>
<p>
</p><p>
</p><blockquote>while [ -n "$line" ]; do </blockquote>
<p>
</p><p>
</p><blockquote>read line || exit 0 </blockquote>
<p>
</p><p>
</p><blockquote>line="${line/M/}" </blockquote>
<p>
</p><p>
</p><blockquote>done </blockquote>
<p>
</p><p>
</p><blockquote>fi </blockquote>
<p>
</p><p>
</p><blockquote>case "$url" in </blockquote>
<p>
</p><p>
</p><blockquote>/) </blockquote>
<p>
</p><p>
</p><blockquote># We need the size of the display for the current applet. </blockquote>
<p>
</p><p>
</p><blockquote># The VNC menubar is 20 pixels high ... </blockquote>
<p>
</p><p>
</p><blockquote>height=$((height+20)) </blockquote>
<p>
</p><p>
</p><blockquote>ctype="text/html" </blockquote>
<p>
</p><p>
</p><blockquote>content=" <HTML><HEAD><TITLE>Remote Desktop</TITLE></HEAD>
<BODY> <APPLET CODE=VncViewer.class ARCHIVE=VncViewer.jar WIDTH=$width
HEIGHT=$height> <param name=PORT value=$port> </APPLET> </BODY></HTML>" </blockquote>
<p>
</p><p>
</p><blockquote>;; </blockquote>
<p>
</p><p>
</p><blockquote>*.jar|*.class) </blockquote>
<p>
</p><p>
</p><blockquote># Use basename to make sure we have just a filename,
not ../../... </blockquote>
<p>
</p><p>
</p><blockquote>url=${url/.*\/} </blockquote>
<p>
</p><p>
</p><blockquote>ctype="application/octet-stream" </blockquote>
<p>
</p><p>
</p><blockquote>cfile="/usr/share/vnc/classes/$url" </blockquote>
<p>
</p><p>
</p><blockquote>content="FILE" </blockquote>
<p>
</p><p>
</p><blockquote>;; </blockquote>
<p>
</p><p>
</p><blockquote>esac</blockquote>
<p>
</p><p>
</p><blockquote>if [ "x$httptype" != "x"
]; then </blockquote>
<p>
</p><p>
</p><blockquote>echo "HTTP/1.0 200 OK" </blockquote>
<p>
</p><p>
</p><blockquote>echo "Content-Type: $ctype" </blockquote>
<p>
</p><p>
</p><blockquote>if [ "$content" == "FILE"
]; then </blockquote>
<p>
</p><p>
</p><blockquote>clen=`wc -c "$cfile"` </blockquote>
<p>
</p><p>
</p><blockquote>else </blockquote>
<p>
</p><p>
</p><blockquote>clen=`echo "$content"|wc -c`</blockquote>
<p>
</p><p>
</p><blockquote>fi </blockquote>
<p>
</p><p>
</p><blockquote>echo "Content-Length: $clen" </blockquote>
<p>
</p><p>
</p><blockquote>echo "Connection: close" </blockquote>
<p>
</p><p>
</p><blockquote>echo </blockquote>
<p>
</p><p>
</p><blockquote>fi</blockquote>
<p>
</p><p>
</p><blockquote>if [ "$request" == "GET"
]; then </blockquote>
<p>
</p><p>
</p><blockquote>if [ "$content" == "FILE"
]; then </blockquote>
<p>
</p><p>
</p><blockquote>cat "$cfile" </blockquote>
<p>
</p><p>
</p><blockquote>else </blockquote>
<p>
</p><p>
</p><blockquote>echo "$content" </blockquote>
<p>
</p><p>
</p><blockquote>fi </blockquote>
<p>
</p><p>
</p><blockquote>fi </blockquote>
<p>
</p><p>
</p><blockquote>exit 0</blockquote>
<p>

</p><p>

</p><h2><a name="SECTION00042000000000000000">
4.2 Configuring the SSHVNC client</a>
</h2>

<p>
Once you have the SSHVNC client extracted and accessible through apache,
you will want to make it easy for your users to connect. You can do
this by specifying most of the ssh and vnc configuration options for
them. This is done by editing the <i>sshvnc-applet.htm</i> file. Here
is an example.

</p><p>
</p><blockquote>
<applet width="820" height="675"
archive="SSHVncApplet-signed.jar,SSHVncApple\t-jdkbug-workaround-signed.jar,SSHVncApplet-jdk1.3.1-dependencies-signed.jar"
code="com.sshtools.sshvnc.SshVNCApplet" codebase="."
style="border-style: solid; border-width: 1; padding-left:
4; padd\ing-right: 4; padding-top: 1; padding-bottom:
1"> </blockquote>
<p>
</p><p>
</p><blockquote><param name="sshapps.connection.connectImmediately"
value="true"> </blockquote>
<p>
</p><p>
</p><blockquote><param name="sshapps.connection.host"
value="my.server.com"> </blockquote>
<p>
</p><p>
</p><blockquote><param name="sshapps.connection.userName"
value=""></blockquote>
<p>
</p><p>
</p><blockquote><param name="sshapps.connection.showConnectionDialog"
value="true"> </blockquote>
<p>
</p><p>
</p><blockquote><param name="sshapps.connection.authenticationMethod"
value="password"> </blockquote>
<p>
</p><p>
</p><blockquote><param name="sshvnc.connection.vncHostDisplay"
value="localhost:5901"> </blockquote>
<p>
</p><p>
</p><blockquote></applet</blockquote>
<p>
You should now be able to connect to your terminal server from anywhere
with any Java enabled web browser. Simply point your browser at the
applet on your web server and it will set up the ssh port forwarding
and VNC connection for you. Remember, VNC is a remote control program,
so you are really just looking at an image of your desktop. You should
be able to do exactly the same things that you can do on an X terminal
on your netowrk. I have found the performance to be excellent over
DSL, and acceptable over dialup. Remember, any fancy graphics, window
managers, background images, etc. will affect your performance. I
am using icewm as my window manager with a simple blank background.

</p><p>

</p><h1><a name="SECTION00050000000000000000">
5 Manual ssh port forwarding</a>
</h1>

<p>
Here are some resources if you would like to learn more about ssh
port forwarding, particularly as it relates to VNC. While this document
focuses on the SSHVNC applet, you can accomplish the same thing with
a VNC client installed on the computer that is accessing remotely,
and ssh port forwarding. On windows you can accomplish the ssh port
forwarding with putty.exe

</p><p>

</p><ul>
<li>VNC port forwarding with ssh: HOWTO - James Lindler - http://www.ltsp.org/contrib/vnc.html
</li>
<li>Making VNC more secure using SSH - http://www.uk.research.att.com/archive/vnc/sshvnc.html
</li>
</ul>

<p>

</p><h1><a name="SECTION00060000000000000000">
6 Conclusion</a>
</h1>

<p>
One of the great advantages of LTSP is the centralized administration
and maintenance. This setup allows you to leverage your existing services
to your users when they are not physically on your network. In a sense,
you are making all your local network services ``web enabled''
with very little additional support overhead. 

</p><p>
I'm sure this document needs improvement. Feedback is appreciated
and ``patches'' are welcome. Also, feel free to contact me if
you have questions. 

</p><p>
<i>Derek.Dresser@gouldacademy.org</i>

</p><p>

</p><h2><a name="SECTION00061000000000000000">
6.1 Caveats</a>
</h2>

<p>
One of the big issues users run into right off using VNC is that there
is no provision for moving files from the terminal server to your
local machine. Right now we deal with this by emailing files from
the terminal server session and then retrieving them locally, but
this is a bit confusing for some people. If anyone knows a simple
web based secure file transfer mechanism, please let me know.

</p><h1><a name="SECTION00070000000000000000">
About this document ...</a>
</h1>
 <strong>Remote LTSP access with SSHVNC applet</strong><p>
This document was generated using the
<a href="http://www-texdev.mpce.mq.edu.au/l2h/docs/manual/"><strong>LaTeX</strong>2<tt>HTML</tt></a> translator Version 2K.1beta (1.48)
</p><p>
Copyright © 1993, 1994, 1995, 1996,
<a href="http://cbl.leeds.ac.uk/nikos/personal.html">Nikos Drakos</a>, 
Computer Based Learning Unit, University of Leeds.
<br>
Copyright © 1997, 1998, 1999,
<a href="http://www.maths.mq.edu.au/%7Eross/">Ross Moore</a>, 
Mathematics Department, Macquarie University, Sydney.
</p><p>
The command line arguments were: <br>
 <strong>latex2html</strong> <tt>-no_subdir -split 0 -show_section_numbers /tmp/lyx_tmpdir3335AjsNpl/lyx_tmpbuf3335kXxQv7/sshvnc.tex</tt>
</p><p>
The translation was initiated by Derek.Dresser@gouldacademy.org on 2004-04-22</p><hr>
<address>
Debian User
2004-04-22
</address>
</body></html>