Page 1 of 1

check_by_ssh host key verification failed

Posted: Thu Oct 23, 2014 3:33 am
by MichielvM
hi,

I have a Linux box on which I need to check diskspace via check_by_ssh.

From the commanline everything looks ok!

Code: Select all

/usr/local/nagios/libexec/check_by_ssh -H x.x.x.x -l nagios -C "/home/nagios/libexec/check_disk -w 10 -c 5 -u GB /app"
DISK OK - free space: /app 85 GB (96% inode=99%);| /app=2GB;83;88;0;93
But when Xi has a go, it returns:

Code: Select all

Remote command execution failed: Host key verification failed.
I've googled a few similar, but not the same, issues. They don't really offer a solution.
I guess this has something to do with how Xi interprets things and I probably need a special character somewhere... But I'm at a loss as to what and where.....

Re: check_by_ssh host key verification failed

Posted: Thu Oct 23, 2014 4:53 am
by MichielvM
addition to the above:

The remote host is an Ubuntu machine.

When I execute the command from cli, the /var/log/auth.log on remote host shows:

Code: Select all

Oct 23 11:29:58 RH-01 sshd[54712]: Accepted publickey for nagios from <Nagios_IP> port 59464 ssh2: RSA <key_id>
Oct 23 11:29:58 RH-01 sshd[54712]: pam_unix(sshd:session): session opened for user nagios by (uid=0)
Oct 23 11:29:59 RH-01 sshd[54760]: Received disconnect from <nagios_ip>: 11: disconnected by user
Oct 23 11:29:59 RH-01 sshd[54712]: pam_unix(sshd:session): session closed for user nagios
When Xi has a go, it shows:

Code: Select all

Oct 23 11:41:55 RH-01 sshd[54817]: Connection closed by <nagios_ip> [preauth]
Oct 23 11:41:55 RH-01 sshd[54814]: Connection closed by <nagios_ip> [preauth]
Oct 23 11:41:55 RH-01 sshd[54815]: Connection closed by <nagios_ip> [preauth]
Oct 23 11:41:55 RH-01 sshd[54816]: Connection closed by <nagios_ip> [preauth]
Which leads me to believe Xi is the culprit here...

Re: check_by_ssh host key verification failed

Posted: Thu Oct 23, 2014 11:04 am
by abrist
Can you show us the service check definition from XI (including args)?
Are you allowing XI to run the check normally through the scheduler, or are you just testing the check? (testing the check will try to run it as apache which will obviously fail)

Re: check_by_ssh host key verification failed

Posted: Fri Oct 24, 2014 2:38 am
by MichielvM
Not entirely sure which you want to see, so here's both.

This is an excerpt from the cfg file (they all fail the same..)

Code: Select all

define service {
        host_name                       amd-zz-lin-01
        service_description             Root App Disk Space
        use                             generic-service
        check_command                   check_xi_by_ssh!-l nagios !-C "/home/nagios/libexec/check_disk -w 10 -c 5 -u GB /app"!!!!!!10.213.232.201
        max_check_attempts              5
        check_interval                  5
        retry_interval                  1
        check_period                    24x7
        notification_interval           60
        notification_period             standbyuren
        notification_options            c,r,
        contacts                        nagiosadmin
        _xiwizard                       sshproxy
        register                        1
        }
A screenie from the same check in Xi (2012R2.9)
Image
$ARG2$ =

Code: Select all

-C "/home/nagios/libexec/check_disk -w 10 -c 5 -u GB /app"

Re: check_by_ssh host key verification failed

Posted: Fri Oct 24, 2014 11:11 am
by Box293
MichielvM wrote:From the commanline everything looks ok!

Code: Select all

/usr/local/nagios/libexec/check_by_ssh -H x.x.x.x -l nagios -C "/home/nagios/libexec/check_disk -w 10 -c 5 -u GB /app"
DISK OK - free space: /app 85 GB (96% inode=99%);| /app=2GB;83;88;0;93
But when Xi has a go, it returns:

Code: Select all

Remote command execution failed: Host key verification failed.
When you test from the command line, are you testing as the nagios user? This is extremely important for check_by_ssh!

Code: Select all

su nagios
/usr/local/nagios/libexec/check_by_ssh -H x.x.x.x -l nagios -C "/home/nagios/libexec/check_disk -w 10 -c 5 -u GB /app"

Re: check_by_ssh host key verification failed

Posted: Wed Nov 05, 2014 3:40 am
by MichielvM
Nailed it.
I generated new ssh keys for user Nagios.