Ajaxterm is a web based terminal. It is a simple solution for those who wish to run a terminal on web. Ajaxterm is fully written in python and Ajax.
Ajaxterm is very simple to install on Linux, MacOS X, FreeBSD,
Solaris, cygwin and any Unix that runs python2.3 or later. Ajaxterm
will listen on port 8022 (by default ) for HTTP requests. You can
change the port to another one.
Ajaxterm will work in most of the POSIX operating systems, including
Linux, MacOS X, FreeBSD, Solaris, etc,. Let us take Centos or RHEL or
fedora as a test environment.
I prefer to read the "README.txt"file within the source code before the install. Here are the steps I followed.
# cd /usr/src
# wget http://antony.lesuisse.org/qweb/files/Ajaxterm-0.10.tar.gz
# tar -xvzf Ajaxterm-0.10.tar.gz
# cd Ajaxterm-0.10/
Now build Ajaxterm as follows.
# ./configure --prefix=/usr/local
# make
# make install
Now the installation is completed. Next step is to configure the web server.
The general idea behind configuring the Ajaxterm with a web server
is to setup a proxy. You can see the configuration of Apache web server
from the README file. It is very easy. Here is the procedure
for configuring with lighttpd.
The lighttpd is a simple, good and lightweight web server You can use the following documentation for installing lighttpd.
http://bobcares.com/article59.html
So after installing the lighttpd web server please proceed with the following instructions.
Make sure the module "mod_proxy" is enabled in the lighttpd configuration file ( /etc/lighttpd/lighttpd.conf)
server.modules = ( "mod_proxy" )
Now configure the proxy module as follows,
proxy.server = ( "/ajaxterm/" =>
(
( "host" => "127.0.0.1",
"port" => 8022
)
)
)
Now in /etc/lighttpd/conf-available/my-proxy.conf add the following,
proxy.server = ( "/cgi/ajaxterm/" =>
(
( "host" => "127.0.0.1",
"port" => 8022
)
)
)
It is your own proxy server configuration. After that please copy the following files to your website document root folder.
# cp -vrf /usr/local/share/ajaxterm/ /home/mydomain.com/
If you wish to configure apache web server with proxy, please add the following in the virtual host entry of your domain.
<proxy *="">
Order deny,allow
Allow from all
</proxy>
ProxyPass /ajaxterm/ http://mydomain.com:8022/
ProxyPassReverse /ajaxterm/ http://mydomain.com:8022/
Also I recommend to configure Ajaxterm with SSL or TSL for secure
connections. Also you can set htpasswd for giving access rights . If so
the apache configuration will be as follows, Listen 443
NameVirtualHost *:443
<virtualhost *:443="">
ServerName localhost
SSLEngine On
SSLCertificateKeyFile ssl/apache.pem
SSLCertificateFile ssl/apache.pem
ProxyRequests Off
<proxy *="">
AuthType Basic
AuthName "remote Shell Access"
AuthUserFile /etc/apache2/htpasswd
Require user tom
Order deny,allow
Allow from all
</proxy>
ProxyPass /ajaxterm/ http://mydomain.com:8022/
ProxyPassReverse /ajaxterm/ http://mydomain.com:8022/
</virtualhost>
Now copy the following files to your website document root folder.
# cp -vrf /usr/local/share/ajaxterm/ /home/mydomain.com/
By default the Ajaxterm will start the program /bin/login. But I have
created a simple login script for Ajaxterm ( using plain authentication
) . I will explain the procedure below,
You can create a login shell by using bash scripting as follows.
First cerate a passwd file,
# cat > /etc/we.shadow << EOF
test:testpasswd
EOF
Now create a shell as follows,
#cat > /bin/webshell << EOF
#!/bin/bash
export _user=`cat /etc/we.shadow| cut -d: -f1`
export _pwd=`cat /etc/we.shadow| cut -d: -f2`
echo -n "Enter Login Name:"
read login
echo -n "Enter Password:"
read pass
if [ $_user = $login ];then
if [ $_pwd = $pass ];then
exec /bin/bash
else
echo "Wrong Authentication"
fi
else
echo "Wrong Authentication !!!"
fi
EOF
Now give execute permission to this script as follows.
# chmod 755 /bin/webshell
So our login shell creation is completed. You can modify the
above script for giving access to more than one users or for giving an
encrypted password authentication.
So after creating the login shell . Let us change the default program
to this shell. So please continue with the following steps.
Edit the startup script /etc/init.d/ajaxterm and modify the following line as given below.
daemon $ajaxterm --daemon --port=$port --uid=$user --command=/bin/webshell $OPTIONS
Here --command=/bin/webshell is the new option added to the startup script, so that the daemon will run this program by default.
By default the Ajaxterm window size is 80x25. You can increase the window width as follows ,
Edit the file /usr/local/share/ajaxterm/ajaxterm.html
# nano /usr/local/share/ajaxterm/ajaxterm.html
window.onload=function() {
t=ajaxterm.Terminal("term",120,30);
};
Now edit the python script /usr/local/share/ajaxterm/ajaxterm.py
#pico /usr/local/share/ajaxterm/ajaxterm.py
def __init__(self,width=120,height=30):
Let us start the Ajaxterm and web server
# /etc/init.d/ajaxterm start
# /etc/init.d/lighttpd restart
If you using apache as web server, then start the service as follows,
# /etc/init.d/ajaxterm start
# /etc/init.d/httpd restart
Now the Ajaxterm is up and running. You can access it as follows.
If you configured the proxy, then access the ajaxterm in the browser as ,
http://mydomaiin.com/ajaxterm
If you don't using the proxy, then access the ajaxterm as ,
http://mydomain.com:8022
The 8022 is the default port. If you wish to change the port,
then change the port in web server configuration file and
/etc/init.d/ajaxterm
hen you access the above mentioned url , then the browser will prompt
for a login information. So now give the login information as mentioned
in /etc/we.shadow
eg:
Enter Login Name: test
Enter Password: testpasswd
bash-3.00$
Now you can " su " to root or any other user . Even you can ssh to another server from this shell.
It is a nice script. It will
help you to access your server terminal from any where in the world.
The only requirements are an Internet connection and a web browser.
1. http://antony.lesuisse.org/qweb/trac/wiki/AjaxTerm
2. http://trac.lighttpd.net/trac/wiki/Ajaxterm
About the author: Sherinmon works as System Administrator. He audits and maintains VPS servers for Datacenters.
In addition to System Administration, his passion is KungFu. He is a certified KungFu master.
|