Today I managed to setup web based terminal on my sheevaplug. It was
an interesting experience, being able to access sheevaplug from
behind firewall from office. Below is the procedure that worked for
me.
- Install apache webserver and enable proxy_http apache module
aptitude install apache2
a2enmod proxy_http
- Build anytermd on sheevaplug
Unfortunately anytermd package is not available in debian, so
you need to build it manually. It needs build-essential, libboost-dev
and zlib1g-dev packages. You need subversion also to checkout
the sources.
aptitude install subversion build-essential
aptitude install libboost-dev zlib1g-dev
svn co http://svn.anyterm.org/anyterm/tags/releases/1.1/1.1.29 anyterm
cd anyterm && make
mkdir ~/bin && cp ./anytermd ~/bin
- Update rc.local to auto start anytermd
You need to start anytermd daemon just built on sheevaplug. It doesn't
come with any init.d scripts. So i decided to start it automatically using
plain old /etc/rc.local mechanism. For this, add
/root/bin/anytermd -c 'ssh %u@localhost' -p 7777 --auth null --user nobody
to /etc/rc.local file before any 'exit 0' statement and run it for current boot session.
sh /etc/rc.local
- Configure and enable virtual-host in apache
If your webserver DNS address is 'plug.homelinux.org', create a new
file with same name in /etc/apache2/sites-available directory.
Update its contents as shown below:
cat /etc/apache2/sites-availabe/plug.homelinux.org
<VirtualHost *:80>
DocumentRoot /srv/www/plug.homelinux.org/htdocs
ServerAdmin iambvk@gmail.com
ServerName plug.homelinux.org
<Proxy *>
Order deny,allow
allow from all
</Proxy>
ProxyRequests Off
SetEnv proxy-chain-auth yes
<Location "/term">
#
# anytermd is executed as:
#
# anytermd -c "/usr/bin/ssh %u@localhost" -p 7777 -u nobody -a null
#
ProxyPass http://localhost:7777 ttl=60
ProxyPassReverse http://localhost:7777
AuthType Basic
AuthName "Web Terminal"
AuthUserFile "/srv/www/plug.homelinux.org/htpasswd"
require valid-user
</Location>
# Logfiles
LogLevel warn
ErrorLog /srv/www/plug.homelinux.org/logs/error.log
CustomLog /srv/www/plug.homelinux.org/logs/access.log combined
</VirtualHost>
Note above that website files would be located in
/srv/www/plug.homelinux.org/htdocs directory and logs go into
/srv/www/plug.homelinux.org/logs directory. So create those
directories and enable the virtual-host:
mkdir -p /srv/www/plug.homelinux.org/htdocs
mkdir -p /srv/www/plug.homelinux.org/logs
a2ensite plug.homelinux.org
Also, notice the Location statement in the above configuration,
which configures apache to redirect all requests to /term
directory (as
http://plug.homelinux.org/term) to
anytermd executing on port 7777 (started from rc.local).
- Create username and passwords to access the web terminal
In the above apache virtual-host configuration, notice the
'AuthUserFile' statement. It configures apache to ask for username
and password when accessing the anytermd location ('/term'). These
username passwords are stored in file,
/srv/www/plug.homelinux.org/htpasswd. You need to create this file
using htpasswd utility:
touch /srv/www/plug.homelinux.org/htpasswd
htpasswd /srv/www/plug.homelinux.org/htpasswd user1
password
Note that this password can be different from the login password
for that user on sheevaplug, but username must match.
Unfortunately user needs to enter two passwords to get access to
the terminal, first one for authenticating with apache (as in
htpasswd) and another for his Linux account login (because
anytermd is configured to execute 'ssh' command automatically when
connected).
- Check apache configuration and reload
apache2ctl configtest
invoke-rc.d apache2 restart
- Open your browser and visit
http://plug.homelinux.org/term to get
the web terminal in action.
I just jope everything works out for you, enjoy :-)