check_by_ssh problem.

Earl C. Ruby III earl at switchmanagement.com
Fri Nov 7 02:04:50 CET 2003


I use check_by_ssh instead of NRPE, but I do it like this:

* Nagios runs under user "nagios" on admin machine.

* Target machine also has a "nagios" user.

* All check scripts for the target live in nagios at target:~/bin and are chmod 
700 (owned by nagios user).

* Generate a dsa keypair for nagios user on admin host using ssh-keygen. 

* Private key is in nagios at admin:~/.ssh/id_dsa

* Public key is in nagios at target:~/.ssh/authorized_keys2

* Verify that ssh works by "su - nagios" on admin, then "ssh nagios at target" 
where "target" is the EXACT host name in ~/etc/hosts.cfg. (If you use IP 
addresses, then "ssh nagios at target_ip_address".)

* The first time you ssh over with the new key and user, you'll get a "add to 
known_hosts" message. Say "yes". (If you skipped this step before, Nagios 
check_by_ssh won't work.)

* Once you've done all of that, you should be able to create commands in 
checkcommands.cfg like so:

define command{
        command_name    check_sensors
        command_line    $USER1$/check_by_ssh -t 15 -H nagios@$HOSTADDRESS$ -C 
'~/bin/check_sensors -w 20 -c 30'
}

If you still decide to use your own Perl script I'd highly recommend NOT 
running the scripts on the target machine as "root" with an ssh key pair 
lying around that can be used by an automated script. Sounds dangerous.

Earl

On Thursday 06 November 2003 02:49 pm, Dmitriy Kropivnitskiy wrote:
> Since nobody answers, I have written my own check_by_ssh in perl. If
> anyone is interested, e-mail me.
>
> Dmitriy Kropivnitskiy wrote:
> > I might be doing something wrong, but I want to run some scripts
> > remotely using check_by_ssh instead of running NRPE daemon.
> > Here is what I did:
> >
> > 1. Compiled fresh check_by_ssh from CVS
> > 2. Generated a dsa keypair using ssh-keygen
> > 3. Copied public key to /root/.ssh/authorized_keys on host1
> > 4. Ran the following command on the server
> > ./check_by_ssh -H host1 -l root -i ./nagios.key -C /usr/local/bin/uptime
> > 5. Got 2 EOL characters with exit code 1 on the output
> >
> > What is wrong?

-- 
Earl C. Ruby III <earl at switchmanagement.com>
Senior Systems Engineer / Developer
Switch Management


-------------------------------------------------------
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