▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
   ██                                                                       ██
  █▌               -   AJAXTERM: WEB BASED SSH TERMINAL   -                  █▌
 █▌                                                                           █▌
 █                                                                            ▐▌
 █ This one is a dream come true :) Imagine the possibilities with SSH        ▐▌
 █ access. Test some demos HERE to see if it will work for your needs.        ▐▌
 █ *If the demo site is blocked on your firewall-it could be because of the   ▐▌  
 █ name  'anyterm' in its path (which is easy to fix on your own setup).      ▐▌
 █                                                                            ▐▌
 █ I adore AjaxTerm. Super easy to install and a right bleepty-beep to get it ▐▌
 █ to work in Apache2! Good luck getting 'proper' help :(                     ▐▌
 █ I never did get it to *work how I 'thought/read' it should, so I just did  ▐▌
 █ a little cheat; stuck in on another SSL port, 8443, that I wasn't          ▐▌
 █ currently using. Bug report page is HERE.                                  ▐▌
 █ *Note when I say work, I mean AjaxTerm working on port 443 without taking  ▐▌
 █ over that entire port/site.                                                ▐▌
 █ From my understanding you can still have a site/other pages on https (443) ▐▌
 █ AND have a working AjaxTerm on the 'same port and same IP' .               ▐▌
 █                                                                            ▐▌
 █ I've condensed my over 30 pages of notes to a working beautiful, easy,     ▐▌
 █ secure, AjaxTerm :) for you.                                               ▐▌
 █                                                                            ▐▌
 █ PREREQUISITES:                                                             ▐▌
 █ ``````````````                                                             ▐▌
 █ If you don't have a SSH browser installed, you need one to test AjaxTerm:  ▐▌
 █ su                                                                         ▐▌
 █ aptitude install lynx                                                      ▐▌
 █                                                                            ▐▌
 █ Of course Apache or another type of www serving software                   ▐▌
 █ aptitude install apache2                                                   ▐▌
 █                                                                            ▐▌
 █ For Apache2 make sure all the modules for proxy have been made available:  ▐▌
 █ a2enmod proxy_http                                                         ▐▌
 █ a2enmod proxy                                                              ▐▌
 █ Or you could do this:                                                      ▐▌
 █ ln -s /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled/proxy.confln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled/proxy.loadln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled/proxy_http.load                                  
 █                                                                            ▐▌
 █ You will need SSL:                                                         ▐▌
 █ aptitude install openssl                                                   ▐▌
 █                                                                            ▐▌
 █ You will need to create a SSL certificate:                                 ▐▌
 █ apt-get install ssl-cert                                                   ▐▌
 █ mkdir /etc/apache2/ssl                                                     ▐▌
 █ /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem                                                
 █ You will be prompted to enter your site's domain. Be sure you delete out   ▐▌
 █ 'localhost' completely from their entry and type in your own site domain.  ▐▌
 █ Example: mewbies.com                                                       ▐▌
 █ That's it, it will exit. By the way creating the cert in this manner it    ▐▌
 █ will be valid for 10 years.                                                ▐▌
 █                                                                            ▐▌
 █ Enable SSL:                                                                ▐▌
 █ a2enmod ssl                                                                ▐▌
 █                                                                            ▐▌
 █ INSTALL AJAXTERM:                                                          ▐▌
 █ `````````````````                                                          ▐▌
 █ su                                                                         ▐▌
 █ apt-get install ajaxterm                                                   ▐▌
 █ /etc/init.d/ajaxterm start                                                 ▐▌
 █ Reply will be: Starting web based terminal: ajaxterm                       ▐▌
 █ exit                                                                       ▐▌
 █                                                                            ▐▌
 █ Test it locally by entering:                                               ▐▌
 █ lynx http://localhost:8022                                                 ▐▌
 █ or just lynx, then: g http://localhost:8022                                ▐▌
 █                                                                            ▐▌
 █ If all is working well your window will refresh and state AjaxTerm top     ▐▌
 █ right. This won't be a workable since SSH can't read java. Exit that now   ▐▌
 █ lets contine.                                                              ▐▌
 █                                                                            ▐▌
 █ PASSWORD TO ACCESS WEB PAGE HAVING AJAXTERM:                               ▐▌
 █ ````````````````````````````````````````````                               ▐▌
 █ pico /etc/ssh/ssh_config                                                   ▐▌
 █ uncomment (remove # before this line): PasswordAuthentication yes          ▐▌
 █ mkdir /srv/ajaxterm                                                        ▐▌
 █ cd /srv/ajaxterm                                                           ▐▌
 █ Make a new web login/password prompt to access AjaxTerm (remember don't    ▐▌
 █ use simple passwords)                                                      ▐▌
 █ htpasswd -cm /srv/ajaxterm/.htpasswd MyName                                ▐▌
 █ Replace MyName with the login name you want to use.                        ▐▌
 █ You will be prompted to type password in twice, you won't see it and you   ▐▌
 █ can't paste it in.                                                         ▐▌
 █                                                                            ▐▌
 █ IF YOUR SSH PORT IS 22 SKIP THIS:                                          ▐▌
 █ `````````````````````````````````                                          ▐▌
 █ AjaxTerm by default will install on port 22 for SSH. If like me you have   ▐▌
 █ changed your SSH port you need to let AjaxTerm know:                       ▐▌
 █ pico /etc/init.d/ajaxterm                                                  ▐▌
 █ It has this:                                                               ▐▌
 █ SERVERPORT=22                                                              ▐▌
 █ I changed that to be my SSH port. For example: SERVERPORT=256              ▐▌
 █                                                                            ▐▌
 █ APACHE2 SETTINGS:                                                          ▐▌
 █ `````````````````                                                          ▐▌
 █ We are going to make a new vhost file, one that doesn't exist:             ▐▌
 █ pico /etc/apache2/sites-available/ajaxterm                                 ▐▌
 █ The code you copy/paste in below you must edit first to your needs:        ▐▌
 █ a. ServerName & Redirect entry 'my.site.org' to your own site's domain     ▐▌
 █ b. All port entries for 8443 to be on a free port you want                 ▐▌
 █ c. The correct path to your apache.pem file, or instead of a .pem you      ▐▌
 █ might have:                                                                ▐▌
 █ SSLCertificateFile /etc/ssl/certs/server.crt                               ▐▌
 █ SSLCertificateKeyFile /etc/ssl/private/server.key                          ▐▌
 █ d. 'require user myname' change myname to the name you entered above       ▐▌
 █ making your .htpasswd                                                      ▐▌
 █ Code to copy/paste in:                                                     ▐▌
 Listen 8443                                                                
                                                                            
 <VirtualHost *:80>                                                         
         ServerName my.site.org                                             
         Redirect 301 / https://ajaxterm.my.site.org:8443                   
         CustomLog /var/log/apache2/access.log combined                     
         ErrorLog /var/log/apache2/error.log                                
 </VirtualHost>                                                             
                                                                            
 <VirtualHost *:8443>                                                       
         ServerName my.site.org                                             
         HostnameLookups Double                                             
         CustomLog /var/log/apache2/access.log combined env=!dontlog        
         SetEnvIf Request_URI "^/u" dontlog                                 
         ErrorLog /var/log/apache2/error.log                                
         Loglevel warn                                                      
         SSLEngine On                                                       
         SSLCertificateFile /etc/apache2/ssl/apache.pem                     
                                                                            
         ProxyRequests Off                                                  
         <Proxy *>                                                          
                 AuthUserFile /srv/ajaxterm/.htpasswd                       
                 AuthName EnterPassword                                     
                 AuthType Basic                                             
                 require user myname                                        
                                                                            
                 Order Deny,allow                                           
                 Allow from all                                             
         </Proxy>                                                           
         ProxyPass / http://localhost:8022/                                 
         ProxyPassReverse / http://localhost:8022/                          
 </VirtualHost>                                                             
 █                                                                            ▐▌
 █                                                                            ▐▌
 █ Then enable it by:                                                         ▐▌
 █ a2ensite ajaxterm                                                          ▐▌
 █                                                                            ▐▌
 █ Reload apache:                                                             ▐▌
 █ /etc/init.d/apache2 reload                                                 ▐▌
 █                                                                            ▐▌
 █ Reload ajaxterm:                                                           ▐▌
 █ /etc/init.d/ajaxterm stop                                                  ▐▌
 █ /etc/init.d/ajaxterm start                                                 ▐▌
 █                                                                            ▐▌
 █ Done :)                                                                    ▐▌
 █ Now go to: https://yoursite.com:8443                                       ▐▌
 █ Accept your self signed certifictate.                                      ▐▌
 █ Login using your normal SSH login.                                         ▐▌
 █                                                                            ▐▌
 █ TROUBLE SHOOTING:                                                          ▐▌
 █ `````````````````                                                          ▐▌
 █ 1) If you receive errors following the cmd 'ajaxterm' in SSH (though it    ▐▌
 █ starts), quit ajaxterm and enter this:                                     ▐▌
 █ killall -15 python                                                         ▐▌
 █ If that still hangs then do:                                               ▐▌
 █ killall -9 python                                                          ▐▌
 █ Then re-start ajaxterm: /etc/init.d/ajaxterm start                         ▐▌
 █                                                                            ▐▌
 █ 2) To quit AjaxTerm properly, as it will keep using system resources,      ▐▌
 █ don't just close the webpage, treat it just like an SSH and type in first: ▐▌
 █ exit                                                                       ▐▌
 █ Then you can close the page.                                               ▐▌
 █                                                                            ▐▌
 █ 3) Firefox: To be able to paste in a java window in Firefox you need to    ▐▌
 █ do some changes.                                                           ▐▌
 █ *I don't recommend this 1st method until a better version comes out: I     ▐▌
 █ installed this addon for firefox HERE. Check HERE for updated version      ▐▌
 █ first, scroll down to find it, it's not the one connected to the download  ▐▌
 █ button.                                                                    ▐▌
 █ *Once I installed this addon it closed firefox without asking and removed  ▐▌
 █ all tabbed sites I had opened (though I have those set to save). Paste     ▐▌
 █ still did not work and the addon wouldn't fully un-install until I         ▐▌
 █ rebooted. grrrr                                                            ▐▌
 █                                                                            ▐▌
 █ So then I did this:                                                        ▐▌
 █ type in address bar: about:config                                          ▐▌
 █ set signed.applets.codebase_principal_support to true ; just double click  ▐▌
 █ on it.                                                                     ▐▌
 █ HERE is the article about how to manually do it.                           ▐▌
 █                                                                            ▐▌
 █ 4) AjaxTerm 0.10-2+lenny1 in Firefox 3.6.x will only show the top tool     ▐▌
 █ bar; no console.                                                           ▐▌
 █ To fix this, I followed the bug report HERE, doing this:                   ▐▌
 █ su                                                                         ▐▌
 █ pico /usr/share/ajaxterm/sarissa.js                                        ▐▌
 █ Change this (line 268):                                                    ▐▌
            XMLDocument.prototype.readyState = 0;
            /**
            * <p>Emulate IE's parseError attribute</p>
            */

 █ To this:                                                                  ▐▌
            try {
                XMLDocument.prototype.readyState = 0;
            } catch(e) {
            };
             /**
             * <p>Emulate IE's parseError attribute</p>
             */
 █                                                                            ▐▌
 █ /etc/init.d/ajaxterm restart                                               ▐▌
 █                                                                            ▐▌
 █ 5) According to the maintainer of AjaxTerm it is not possible to have a    ▐▌
 █ scroll bar on AjaxTerm's console window. If you want a longer scroll back  ▐▌
 █ then the best method is to increase the height of the console window. Keep ▐▌
 █ in mind that with every key stroke the entire window is updated, so the    ▐▌
 █ larger the window, the slower the response might be.                       ▐▌
 █                                                                            ▐▌
 █ 6) To resize AjaxTerm's terminal window you need to edit 2 files:          ▐▌
 █ su                                                                         ▐▌
 █ pico /usr/share/ajaxterm/ajaxterm.py                                       ▐▌
 █ Has this:                                                                  ▐▌
 █         def __init__(self,width=80,height=24):                             ▐▌
 █ Changed to:                                                                ▐▌
 █         def __init__(self,width=130,height=48):                            ▐▌
 █                                                                            ▐▌
 █ pico /usr/share/ajaxterm/ajaxterm.html                                     ▐▌
 █ Has this:                                                                  ▐▌
 █       t=ajaxterm.Terminal("term",80,25);                                   ▐▌
 █ Changed to:                                                                ▐▌
 █      t=ajaxterm.Terminal("term",130,48);                                   ▐▌
 █                                                                            ▐▌
 █ I also made a few minor change's to its page:                              ▐▌
 █ Changed title and after the meta tag added:                                ▐▌
 █ <link rel="icon" href="favicon.ico" type="image/x-icon" />                 ▐▌
 █ <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />        ▐▌
 █ Then upload your own favicon.ico to /usr/share/ajaxterm/                   ▐▌
 █ Btw you can make quick simple favicon.ico HERE on on-line                  ▐▌
 █ *Note: When I made my window height larger than 99 it reverted back to     ▐▌
 █ its original size.                                                         ▐▌
 █                                                                            ▐▌
 █ To have the changes take affect you'll need to restart AjaxTerm:           ▐▌
 █ /etc/init.d/ajaxterm restart                                               ▐▌
 █ Upon which if you get this error when going to its web page:               ▐▌
 █ "Service Temporarily Unavailable                                           ▐▌
 █ The server is temporarily unable to service your request due to            ▐▌
 █ maintenance downtime or capacity problems. Please try again later."        ▐▌
 █ I had to stop and start mine a few times:                                  ▐▌
 █ /etc/init.d/ajaxterm stop                                                  ▐▌
 █ /etc/init.d/ajaxterm start                                                 ▐▌
 █ exit                                                                       ▐▌
 █                                                                            ▐▌
 █ 7) Files are here:                                                         ▐▌
 █ /etc/default/ajaxterm                                                      ▐▌
 █ /etc/init.d/ajaxterm                                                       ▐▌
 █ /usr/bin/ajaxterm                                                          ▐▌
 █ /usr/share/ajaxterm/ajaxterm.css                                           ▐▌
 █ /usr/share/ajaxterm/ajaxterm.html                                          ▐▌
 █ /usr/share/ajaxterm/ajaxterm.js                                            ▐▌
 █ /usr/share/ajaxterm/ajaxterm.py                                            ▐▌
 █ /usr/share/ajaxterm/qweb.py                                                ▐▌
 █ /usr/share/ajaxterm/sarissa.js                                             ▐▌
 █ /usr/share/ajaxterm/sarissa_dhtml.js                                       ▐▌
 █ /usr/share/doc/ajaxterm/README.Debian                                      ▐▌
 █ /usr/share/doc/ajaxterm/README.txt.gz                                      ▐▌
 █ /usr/share/doc/ajaxterm/changelog.Debian.gz                                ▐▌
 █ /usr/share/doc/ajaxterm/copyright                                          ▐▌
 █ /usr/share/lintian/overrides/ajaxterm                                      ▐▌
 █ /usr/share/man/man1/ajaxterm.1.gz                                          ▐▌
 █ /usr/share/python-support/ajaxterm.dirs                                    ▐▌
 █                                                                            ▐▌
 █ 8) Here are just a few of the places you can read about getting this to    ▐▌
 █ work on Apache2:                                                           ▐▌
 █ (I have tried all of these settings and then some; either apache2 stops    ▐▌
 █ working or entire https (443) site is ajaxterm only)                       ▐▌
 █ Debian-Maintainer  Ubuntu  Wiki  Wiki  Bobcares                            ▐▌
 █                                                                            ▐▌
 █                                                                            ▐▌
 █ //----------------------------------------------------------------------   ▐▌
 █                                                                            ▐▌
 █ If you find mistakes, have suggestions, and or questions please post at    ▐▌
 █ mewbies forum HERE - thank you.                                            ▐▌
 █                                                                            ▐▌
 █ Last update on 01 Aug '10                                                  ▐▌
 █                                                                            ▐▌
 █▌                                                                           █▌
  █▌                          -   mewbies.com   -                            █▌
   █▌                                                                       █▌
    ██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██