CGI bash or perl script to run ssh

Peter Edmonds pedmonds at boursedata.com.au
Wed Nov 26 08:24:31 CET 2003


Ok. Now it makes sense. ssh could not create the .ssh directory, nor store
the known_hosts file

This works now

#!/bin/bash
ssh -l <username> -i <Identity for public key authentication>
host_ip_address command > service_result
cat service_result | mail -s "SSH command run via cgi" user at host
        service_result=`cat service_result`
 echo "Content-type: text/html"
 echo ""
 echo "<HTML><HEAD></HEAD><BODY>"
 echo "<H2>SSH command run via cgi</H2>"
 echo "<HR>"
 echo "$service_result"
 echo "</BODY></HTML>"

So now, clicking on the serviceextinfo link runs the cgi script and returns
the results as a HTML page - useful if you restart a service or something
similar.

Peter Edmonds

-----Original Message-----
From: nagios-users-admin at lists.sourceforge.net
[mailto:nagios-users-admin at lists.sourceforge.net]On Behalf Of Spyou
Sent: Wednesday, 26 November 2003 5:38 PM
To: nagios-users at lists.sourceforge.net
Subject: Re: [Nagios-users] CGI bash or perl script to run ssh


At 00:31 26/11/2003, Peter Edmonds wrote:
>Can anyone provide an example cgi bash or perl script to run ssh ?
>
>I'd like to be able to have a link in the Extended Service information
which
>would run a cgi that would ssh to a remote machine and run a specific
>command.

#!/bin/sb

ssh remotelogin at remotehost command


you'll have to make ssh public key exchange working between your monitoring
box and your remote host in order to avoid password prompt (see
http://cfm.gs.washington.edu/security/ssh/client-pkauth/)


Regards,
____________________________________
  'Spyou' - www.spyou.org - root at spyou.org
     #gtr / ircnet.kaptech.fr - UIN : 6871374

Please, tell me who i am !
- Supertramps




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting
any issue.
::: Messages without supporting info will risk being sent to /dev/null



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list