Thursday 26 June 2014

Guacamole Remote Desktop with Debian Wheezy & websockets

I came across Guacamole when looking for a webinar solution for work.  The current packaged version with Debian Wheezy is too out of date (0.6.0) and too slow.  The latest version (0.9.1 at this time) supports Websockets instead of HTTP connections which speeds it up a fair bit.

I did initially test 0.6.0 but it was very slow (at least 5 seconds delay) to update client screens even with just a single client logged in.

It does mean however:

  • you must manually compile guacamole-server from source
  • you need to use Tomcat 7 with a higher version number than 7.0.37 but Wheezy only has 7.0.28
I have all this running on a fairly basic virtual server (running inside Proxmox) with 2GB of memory and it coped pretty well with about 10 people connected to it (1 in control mode, 9 in view-only).

This isn't really what Guacamole was invented for, it's designed to be a web-based front end for remotely accessing PCs over VNC or RDP.  I am using it for webinars with a lot more people connected to a single session than you'd get for remote support or accessing your own PC from home etc...

How I got it working....

New enough version of Tomcat7:
  • add wheezy-backports repo to sources.list.  E.G. :
deb http://mirror.bytemark.co.uk/debian wheezy-backports main contrib non-free
  •  Install Tomcat 7 from backports:
apt-get update; apt-get -t wheezy-backports install tomcat7

Latest release of Guacamole:

  • go to: http://guac-dev.org/releases/
  • then click the latest version (everything I did here was with version 0.9.1)
  • you need to download the guacamole "war" file.  This is the Java Servlet that you'll deploy in Tomcat 7.  Being Java it's cross-platform so no need to compile this bit.
  • guacamole-server.....tar.gz.  This is the source for the guacamole server which you'll need to compile.
  • install the necessary libraries:
apt-get install build-essential libpng12-dev libcairo2-dev libvncserver-dev
Note: this'll get you a fairly minimal install with support for VNC.  Other packages are required if you want support for RDP, SSH and sound.  Refer to the guac-dev.org website

  • untar the guacamole-server source download and cd into the folder
  • run the configure script:
./configure --with-init-dir=/etc/init.d
  • This should complete with success and tell you which protocols and options will be supported when built.  If you want more options then install more libraries as required and re-run the config script
  • Otherwise, just do:
make
  • Once it's finished:
make install 
  •  deploy the servlet (your version code may differ):
cp guacamole-0.9.1.war /var/lib/tomcat7/webapps/guacamole.war
  •  you need two config files for guacamole.  The first, is /etc/guacamole/guacamole.properties.  Mine looks like this:
guacd-hostname: localhost
guacd-port:     4822
auth-provider: net.sourceforge.guacamole.net.basic.BasicFileAuthenticationProvider 
basic-user-mapping: /etc/guacamole/user-mapping.xml 
enable-websocket: true
  • The 2nd file is /etc/guacamole/user-mapping.xml.  This contains the logins and links to VNC servers.  Mine is similar to this:
<authorize username="demo" password="demo">
    <connection name="localhost">
        <protocol>vnc</protocol>
        <param name="hostname">127.0.0.1</param>
        <param name="port">5900</param>
        <param name="password">viewer</param>
    </connection>
</authorize>
  • That defines a single login with a single connection for a VNC server running on local host with a password of "viewer".  Lots of people can log in to the Guacamole web interface at once with the username "demo" & password "demo".  Note - please don't use these actual values as passwords!!!
  • Create a link to the config file for the guacamole servlet: 
ln -s /etc/guacamole/guacamole.properties /usr/share/tomcat7/.guacamole/
  • That's about it, start up tomcat7 and Guacamole:
service tomcat7 start
service guacd start 
Then start the VNC server itself.  In this case I'm running all this on a headless server but I have Gnome Desktop Environment installed and tightvncserver.  I just start a vnc server and leave it running all the time:
apt-get install tightvncserver
vncserver :0 (not as root, use another user)
The way I use this is that when starting vnc server, I create one password for control and another password (which matches the one in the guacamole settings above) for view only.

I then VNC into the server from my own PC here using any VNC client (I use Remmina front end) and log in using the control password.

All the webinar participants then log in by simply web browsing to my Guacamole installation and logging in there (which gives them all view-only VNC sessions).  Since I run the desktop environment on the server itself, I have only a single VNC session from my PC here to the hosted server which then has lots of connections from clients.

It seems to work very well.  My next task is to install Asterisk PBX onto the server and run a conference room for people to dial in for the audio of the webinar.  Longer term - log caller IDs and things from people in the conference and display them to the person in control of the webinar.