Ad Widget

Collapse

"SSH Connect" in Dashboard context menu - HOWTO

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • koska
    Junior Member
    • Apr 2009
    • 7

    #16
    Are you sure that your path for your mindterm.jar is good ?

    ARCHIVE="/var/www/zabbix/mindterm/mindterm.jar"

    If you use IE remember you need to download mindterm_ie.cab and put it in the same repertory.

    Comment

    • zigli
      Junior Member
      • May 2009
      • 11

      #17
      Great feature! It works good.

      Here is the singed applet http://weavervsworld.com/ssh/ssh.php
      I hope it helps someone.

      Comment

      • Mike Cotrone
        Junior Member
        • Feb 2009
        • 21

        #18
        what was your solution?

        Originally posted by koska
        Hi,

        It looks very nice but I have a problem with the new scripts_exec.php.

        When I put it, all my scripts work but I have an error message.



        Any ideas ?

        Cheers
        I have the same issue and I am using your scripts_exec.php file. I did change my script id to 11 and made sure my path to mindterm is correct.

        I still have this issue.
        Thanks

        Comment

        • bashman
          Senior Member
          • Dec 2009
          • 432

          #19
          Does this work with zabbix v1.8.4?
          978 Hosts / 16.901 Items / 8.703 Triggers / 44 usr / 90,59 nvps / v1.8.15

          Comment

          • efrain02
            Banned
            • Apr 2011
            • 81

            #20
            I'm wondering the same thing... this would be great in zabbix 1.8.4

            Comment

            • zigli
              Junior Member
              • May 2009
              • 11

              #21
              i do it like this

              Create a script Ssh



              then create /usr/local/bin/cmd bash script
              set necessary permissions to the file
              also you need to install on your system php-cgi




              and here is zz.php

              PHP Code:
              <?
              if($argv[1]=="") exit;
              if($argv[2]=="ssh"){
              ?>
              <APPLET CODE="com.mindbright.application.MindTerm.class"  ARCHIVE="http://192.168.225.250/mindterm.jar" WIDTH=0 HEIGHT=0>
              <PARAM NAME=cabinets value="mindterm_ie.cab">
              <PARAM NAME=sepframe value="true">
              <PARAM NAME=debug value="true">
              <PARAM NAME=protocol value="ssh2">
              <PARAM NAME=server value="<?php echo $argv[1];?> ">
              <PARAM NAME=port value="50022">
              <PARAM NAME=geometry value="100x24">
              <PARAM NAME=encoding value="utf-8">
              <PARAM NAME=x11-forward value="true">
              <PARAM NAME=x11-display value="localhost:0">
              <PARAM NAME=compression value="3">
              <PARAM NAME=visual-bell value="true">
              <PARAM NAME=bg-color value="black">
              <PARAM NAME=fg-color value="white">
              <PARAM NAME=exit-on-logout value="true">
              <PARAM NAME=cursor-color value="i_green">
              </APPLET>
              <?
              }
              ?>

              Comment

              • efrain02
                Banned
                • Apr 2011
                • 81

                #22
                It look great... is for 1.8.4??

                Comment

                • bashman
                  Senior Member
                  • Dec 2009
                  • 432

                  #23
                  Here's the scripts_exec.php for Zabbix v1.8.4
                  Attached Files
                  978 Hosts / 16.901 Items / 8.703 Triggers / 44 usr / 90,59 nvps / v1.8.15

                  Comment

                  • zigli
                    Junior Member
                    • May 2009
                    • 11

                    #24
                    Originally posted by efrain02
                    It look great... is for 1.8.4??
                    Yes! It works on 1.8.4.

                    Comment

                    • efrain02
                      Banned
                      • Apr 2011
                      • 81

                      #25
                      Originally posted by zigli
                      Yes! It works on 1.8.4.
                      Thanks! I'm trying to use it, but i just don't understand if the script name is cmd or is the directory and where can i find information to know if i had php-cgi.
                      I'm going to look for more info.

                      Thanks again

                      Comment

                      • zigli
                        Junior Member
                        • May 2009
                        • 11

                        #26
                        Originally posted by efrain02
                        Thanks! I'm trying to use it, but i just don't understand if the script name is cmd or is the directory and where can i find information to know if i had php-cgi.
                        I'm going to look for more info.

                        Thanks again
                        just try to run simple script from console
                        For example test.php
                        PHP Code:
                        <?
                        echo "Hello";
                        ?>
                        run it like
                        php /path/to/script/test.php
                        and you should see output Hello

                        if not, you have to install php-cgi
                        on my Debian like this
                        aptitude install php5-cgi

                        Comment

                        • efrain02
                          Banned
                          • Apr 2011
                          • 81

                          #27
                          Ok. thank you. Now i just need to figure out how to make the bash script. If you could upload that would be great!.

                          Comment

                          • sire
                            Senior Member
                            • Jul 2010
                            • 210

                            #28
                            Here is how I do this.

                            1. Get Shell In A Box AJAX web ssh/telnet shell.

                            2. Compile and install it, but don't start it as a service.

                            3. Edit the following telnet.sh and ssh.sh and put them into the cgi-bin directory of your web server that is hosting Zabbix frontend.

                            PHP Code:
                            #!/bin/bash

                            # ssh.sh
                            # This is a CGI script that uses shellinabox in CGI mode.

                            function connect {
                                
                            shellinaboxd --cgi -/var/lib/shellinabox -/:SSH:$parms
                                
                            if [ $? -ne 0 ]; then
                                
                            echo "$res> /tmp/1.log
                                cannot_connect
                                fi
                            }

                            function default {
                                 
                            # First time that the CGI script was called. Show initial HTML page.
                                 
                            printf 'Content-Type: text/html\r\n\r\n'
                                 
                            cat <<EOF
                                 
                            <html>
                                   <
                            head>
                                     <
                            title>SSH Shell</title>
                                   </
                            head>
                                   <
                            body>
                                     <
                            h1>SSH Shell</h1>

                                     <
                            p>Enter address to connect to:
                                     <
                            form method="POST">
                                       <
                            input type="text" name="cmd" style="width: 40em" value="127.0.0.1" />
                                     </
                            form>
                                     </
                            p>
                                   </
                            body>
                            EOF
                            }

                            function 
                            cannot_connect {
                                 
                            printf 'Content-Type: text/html\r\n\r\n'
                                 
                            cat <<EOF
                                 
                            <html>
                                   <
                            head>
                                     <
                            title>SSH Shell</title>
                                   </
                            head>
                                   <
                            body>
                                     <
                            h1>SSH Shell</h1>

                                     <
                            p>Unable to establish connection with $parms</p>
                                   </
                            body>
                            EOF
                            }

                            case 
                            "${REQUEST_METHOD}in
                              GET
                            )
                                 
                            # Retrieve CGI parameter, then start shellinabox with this address
                                 
                            parms=`echo $QUERY_STRING`
                                 if [ 
                            "$parms!= "" ]; then
                                    connect $parms
                                 
                            else
                                    default
                                 
                            fi
                                 
                            ;;

                              
                            POST)
                                 
                            # Retrieve CGI parameter, then start shellinabox with this address
                                 
                            read parms
                                 parms
                            ="$(printf "$(echo "${parms}"|sed -'s/%\(..\)/\\x\1/g;s/%/%%/g')")" #"
                                 
                            parms="${parms#cmd=}"
                                 
                            if [ "$parms!= "" ]; then
                                    connect $parms
                                 
                            else
                                    default
                                 
                            fi
                                 
                            ;;

                              *)
                                 default
                                 ;;
                            esac 
                            PHP Code:
                            #!/bin/bash

                            # telnet.sh
                            # This is a CGI script that uses shellinabox in CGI mode.

                            function connect {
                                
                            shellinaboxd --cgi -/var/lib/shellinabox -"/:$(id -u):$(id -g):HOME:telnet ${parms}"
                                
                            if [ $? -ne 0 ]; then
                                cannot_connect
                                fi
                            }

                            function default {
                                 
                            # First time that the CGI script was called. Show initial HTML page.
                                 
                            printf 'Content-Type: text/html\r\n\r\n'
                                 
                            cat <<EOF
                                 
                            <html>
                                   <
                            head>
                                     <
                            title>Telnet Shell</title>
                                   </
                            head>
                                   <
                            body>
                                     <
                            h1>Telnet Shell</h1>

                                     <
                            p>Enter address to connect to:
                                     <
                            form method="POST">
                                       <
                            input type="text" name="cmd" style="width: 40em" value="127.0.0.1" />
                                     </
                            form>
                                     </
                            p>
                                   </
                            body>
                            EOF
                            }

                            function 
                            cannot_connect {
                                 
                            printf 'Content-Type: text/html\r\n\r\n'
                                 
                            cat <<EOF
                                 
                            <html>
                                   <
                            head>
                                     <
                            title>Telnet Shell</title>
                                   </
                            head>
                                   <
                            body>
                                     <
                            h1>Telnet Shell</h1>

                                     <
                            p>Unable to establish connection with $parms</p>
                                   </
                            body>
                            EOF
                            }

                            case 
                            "${REQUEST_METHOD}in
                              GET
                            )
                                 
                            # Retrieve CGI parameter, then start shellinabox with this address
                                 
                            parms=`echo $QUERY_STRING`
                                 if [ 
                            "$parms!= "" ]; then
                                    connect $parms
                                 
                            else
                                    default
                                 
                            fi
                                 
                            ;;

                              
                            POST)
                                 
                            # Retrieve CGI parameter, then start shellinabox with this address
                                 
                            read parms
                                 parms
                            ="$(printf "$(echo "${parms}"|sed -'s/%\(..\)/\\x\1/g;s/%/%%/g')")" #"
                                 
                            parms="${parms#cmd=}"
                                 
                            if [ "$parms!= "" ]; then
                                    connect $parms
                                 
                            else
                                    default
                                 
                            fi
                                 
                            ;;

                              *)
                                 default
                                 ;;
                            esac 
                            4. Ensure that your cgi-bin directory is enabled in your web server config and cgi-scripts are accessible from a web browser.

                            5. Create /var/lib/shellinabox directory and make it rwx-accessible by your web server process, i.e. apache, nobody, whatever it is. Or just chmod it to 777, which is a security hole.

                            6. Open Zabbix network map editor, chose a host to edit and type in the URL field: http://<Your Zabbix Web Server Address>/cgi-bin/telnet.sh?<IP Address Of A Network Host>

                            7. Save the map, open it in the map viewer, point at the edited icon and click the URL link. A telnet window will replace your current browser tab.

                            If you have firewalling on your Zabbix server enabled your browser will likely fail to connect to Shellinabox. In this case temporary enable all incoming connections to check it's working and tune your firewall.

                            There are other web shells such as Ajaxterm, js_terminal, nixs, webshell, webtty, and probably others, but I didn't try them because Shellinabox just worked.
                            Last edited by sire; 14-12-2011, 11:27. Reason: Refined formatting
                            Regards,
                            Sergey Syreskin

                            Monitored hosts: 2646 / Active items: 23604 / Server performance: 765.74

                            Temporary out of Zabbix business

                            Comment

                            • prostrelov
                              Senior Member
                              • May 2012
                              • 115

                              #29
                              Debian 6.0.3 Apache 2.2.x Php 5.3.x Zabbix 2.0.2

                              Got a problem with shellinabox:

                              nano /etc/apache2/httpd.conf
                              Code:
                              ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
                              ls -al
                              drwxrwxrwx 2 root root 4096 Aug 2 13:18 .
                              drwxr-xr-x 132 root root 57344 Aug 1 17:12 ..
                              -rwxrwxrwx 1 www-data www-data 2007 Aug 2 12:53 ssh.sh
                              -rwxrwxrwx 1 root root 2032 Aug 2 11:29 telnet.sh
                              -rwxrwxrwx 1 root root 76 Aug 2 11:19 test.pl

                              #!/usr/bin/perl
                              print "Content-type: text/html\n\n";
                              print "Hello, World.";
                              Hello World

                              #!/bin/bash
                              echo "Content-Type: text/html;charset=utf-8\r\n"
                              echo ''
                              echo '<h1>test</h1>'
                              Hello World

                              SSH Shell
                              Unable to establish connection with echo $QUERY_STRING


                              Session closed.
                              /var/log/apache2/error.log
                              Code:
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] Usage: shellinaboxd [OPTIONS]...
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] Starts an HTTP server that serves terminal emulators to AJAX enabled browsers.
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] 
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] List of command line options:
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -b, --background[=PIDFILE]  run in background
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -c, --cert=CERTDIR          set certificate dir (default: $PWD)
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]       --cert-fd=FD            set certificate file from fd
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]       --css=FILE              attach contents to CSS style sheet
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]       --cgi[=PORTMIN-PORTMAX] run as CGI
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -d, --debug                 enable debug mode
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -f, --static-file=URL:FILE  serve static file from URL path
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -g, --group=GID             switch to this group (default: www-data)
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -h, --help                  print this message
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]       --linkify=[none|normal|agressive] default is "normal"
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]       --localhost-only        only listen on 127.0.0.1
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]       --no-beep               suppress all audio output
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -n, --numeric               do not resolve hostnames
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -p, --port=PORT             select a port (default: 4200)
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -s, --service=SERVICE       define one or more services
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -t, --disable-ssl           disable transparent SSL support
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]       --disable-ssl-menu      disallow changing transport mode
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -q, --quiet                 turn off all messages
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -u, --user=UID              switch to this user (default: www-data)
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]       --user-css=STYLES       defines user-selectable CSS options
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   -v, --verbose               enable logging messages
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]       --version               prints version information
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] 
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] Debug, quiet, and verbose are mutually exclusive.
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] 
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] One or more --service arguments define services that should be made available
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] through the web interface:
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   SERVICE := <url-path> ':' APP
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   APP     := 'LOGIN' | 'SSH' [ : <host> ] | USER ':' CWD ':' <cmdline>
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   USER    := 'AUTH' | <username> ':' <groupname>
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   CWD     := 'HOME' | <dir>
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] 
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] <cmdline> supports variable expansion:
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   ${columns} - number of columns
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   ${gid}     - gid id
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   ${group}   - group name
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   ${home}    - home directory
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   ${lines}   - number of rows
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   ${peer}    - name of remote peer
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   ${uid}     - user id
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   ${url}     - the URL that serves the terminal session
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   ${user}    - user name
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] 
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] One or more --user-css arguments define optional user-selectable CSS options.
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] These options show up in the right-click context menu:
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   STYLES  := GROUP { ';' GROUP }*
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   GROUP   := OPTION { ',' OPTION }*
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114]   OPTION  := <label> ':' [ '-' | '+' ] <css-file>
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] 
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] OPTIONs that make up a GROUP are mutually exclusive. But individual GROUPs are
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] independent of each other.
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] 
                              [Fri Aug 10 11:42:29 2012] [error] [client 192.168.213.114] Failed to parse command line
                              So as u can see - ssh.sh didn't work propertly from direct usage

                              p.s.
                              can someone tell me what does this code do:
                              Code:
                                POST)
                                   # Retrieve CGI parameter, then start shellinabox with this address
                                   read parms
                                   parms="$(printf "$(echo "${parms}"|sed -e 's/%\(..\)/\\x\1/g;s/%/%%/g')")" #"
                                   parms="${parms#cmd=}"
                                   if [ "$parms" != "" ]; then
                                      connect $parms
                                   else
                                      default
                                   fi
                                   ;;
                              
                                *)
                                   default
                                   ;;
                              Last edited by prostrelov; 14-08-2012, 12:17.

                              Comment

                              • prostrelov
                                Senior Member
                                • May 2012
                                • 115

                                #30
                                By the way this script is working fine.

                                Code:
                                #!/bin/sh
                                 shellinaboxd --cgi -c /var/lib/shellinabox -s /:SSH:192.168.213.133
                                So we can't get ip adress from url and give it to shellinabox propertly in Sire's script

                                Comment

                                Working...