How to Configure AnyTerm Web-based SSH on Ubuntu

Anyterm provides a web-based SSH interface that would allow you to, for example, access your internal system using SSH via a web page. Configuration is straightforward, but will require compiling the Anyterm source. In order to download the source, you’ll need Subversion.

  1. Download Anyterm (http://anyterm.org/download.html) into a directory called anyterm
  2. Make sure you have the following development libraries:
    • GNU Compiler Collection
      # sudo apt-get install build-essential
      
    • Boost
      # sudo apt-get install libboost-all-dev
      
    • ncurses
      # sudo apt-get install libncurses-dev
      
  3. Next, you’ll need to optimize make to your specific architecture (in my case, an Atom CPU). Edit anyterm/common.mk:
    GCC_FLAGS=-pthread
    

    to

    GCC_FLAGS=-pthread -march=atom
    
  4. Edit anyterm-1.1.29/browser/anyterm.html specific to your needs. In my case, I’ve allowed the specification of the hostname in the HTML, but hard coded the username in the daemon process. This was merely for testing purposes; ensure that you use security best practices as to not allow easy access to internal systems:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <!--
    browser/anyterm.html
    This file is part of Anyterm; see http://anyterm.org/
    (C) 2005-2007 Philip Endecott
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    -->
    
    <html>
    <head>
    <title>Anyterm</title>
    
    <script type="text/javascript" src="anyterm.js">
    </script>
    
    <script type="text/javascript">
      // To create the terminal, just call create_term.  The paramters are:
      //  - The id of a <div> element that will become the terminal.
      //  - The title.  %h and %v expand to the hostname and Anyterm version.
      //  - The number of rows and columns.
      //  - An optional parameter which is substituted for %p in the command string.
      //  - An optional character set.
      //  - An option number of lines of scrollback (default 0).
      function get_url_param(name) {
        name = name.replace(/[[]/,"\[").replace(/[]]/,"\]");
        var regexS = "[\?&]"+name+"=([^&#]*)";
        var regex = new RegExp( regexS );
        var results = regex.exec( window.location.href );
        if( results == null )
          return "";
        else
          return results[1];
      }
      var host = get_url_param("host");
      window.onload=function() {create_term("term",host,25,80,host,"",50);};
    
      // When the user closes the terminal, by default they'll see a blank page.
      // Generally you'll want to be more friendly than that.  If you set the
      // variable on_close_goto_url to a URL, they'll be sent to that page after
      // closing.  You could send them back to your home page, or something.
      var on_close_goto_url = "";
    
    </script>
    
    <link rel="stylesheet" type="text/css" href="anyterm.css">
    
    </head>
    
    <body>
    
    <noscript>Javascript is essential for this page.  Please use a browser
    that supports Javascript.</noscript>
    
    <div id="term"></div>
    
    </body>
    </html>
    
  5. Run make (make sure you’re in the anyterm directory):
    # make
    
  6. Copy created binary to /usr/sbin:
    # sudo cp anytermd /usr/sbin/
    
  7. Add the following to /etc/rc.local, which will run the Anyterm daemon on port 8022 on startup:
    /usr/sbin/anytermd -u root -p 8022 -c 'ssh myuser@%p'
    

    NOTE: It’s highly recommended NOT to run the anytermd as root, so make sure you change the user from root to an unprivileged one; root was used in this case just to get the system running.

  8. Lastly, test your system (after you reboot) by accessing the Anyterm daemon via http://localhost:8022/anyterm.html?host=192.168.1.1