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 installation
Software requirements
Installation procedures
. Web server configuration
Lighttpd web server configuration
Apache web server configuration
Ajaxterm hacking
Login shell creation
Editing the startup script
Increasing the terminal window size
Start Ajaxterm
Conclusion
A. References
Hire Bobcares Linux Server Administrators
Get super reliable servers and delighted customers
Ajaxterm install
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.
Software requirements
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.
Installation procedures
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.
Web server configuration
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.
Lighttpd web server configuration
The lighttpd is a simple, good and lightweight web server You can use the following documentation for installing lighttpd.
https://bobcares.com/blog/llmp-configuration/
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/
Apache web server configuration
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/
Ajaxterm hacking
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,
Login shell creation
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.
5.2 Editing the startup script
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.
Increasing the terminal window size
By default the Ajaxterm window size is 80×25. 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):
Start Ajaxterm
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/ajaxtermhen 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.
Conclusion
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.
A. References
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.
I’m a bit confused on how to add a virtual host entry into apache. Could you break that down a bit further for me? I’m still a bit new to Linux and am learning a lot.
Thanks in advance!
Is there a way to make the terminal window scorll? That way if I issue something like ps -e all of the info will show.
Hi!
i m bit new to coding..i have a web page in which i login with username and password…now as my user had once given username and passwd i dont want him to supply again…in short i want to get rid off dat login prompt by ajaxterm..like when user clicks on openterminal…it shud directly login in the machine..ny idea how to do dat…???
Regards
Arpit
hi
nice article.
I need some help to install ajaxterm in debian 5
i am going to use this for free community linux shell accounts
Kindly reply when ever u r free
Thanks
@SerialTux
When you make the terminal really high, then you can scroll it with the browser scroll bar…
I would like AjaxTerm login to another thirdparty server. Is it possible ?