check_by_ssh host key verification failed

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
MichielvM
Posts: 160
Joined: Thu Oct 24, 2013 3:48 am

check_by_ssh host key verification failed

Post 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.....
MichielvM
Posts: 160
Joined: Thu Oct 24, 2013 3:48 am

Re: check_by_ssh host key verification failed

Post 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...
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_by_ssh host key verification failed

Post 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)
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
MichielvM
Posts: 160
Joined: Thu Oct 24, 2013 3:48 am

Re: check_by_ssh host key verification failed

Post 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"
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: check_by_ssh host key verification failed

Post 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"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
MichielvM
Posts: 160
Joined: Thu Oct 24, 2013 3:48 am

Re: check_by_ssh host key verification failed

Post by MichielvM »

Nailed it.
I generated new ssh keys for user Nagios.
Locked