Remote command execution failed: Host key verification faile

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
danoreilly
Posts: 28
Joined: Mon Dec 01, 2014 4:28 pm

Remote command execution failed: Host key verification faile

Post by danoreilly »

Doing the monitoring by SSH. I have a nagios public key set up properly. As user nagios from my nagios server, I can ssh to the target remote node as nagios just fine, so I know key authentication is set up properly. However, none of the commands I set up work. They all fail with "Remote command execution failed: Host key verification failed.". I'm at a loss to explain why.

A sample command definition is:

define command{
command_name check_byssh_disk
command_line $USER1$/check_by_ssh -H $HOSTADDRESS$ -n $HOSTNAME$ -C '$USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$'
}
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Remote command execution failed: Host key verification f

Post by eloyd »

Can you do this as the nagios user:

Code: Select all

ssh <remote host> hostname
From the command line?
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
danoreilly
Posts: 28
Joined: Mon Dec 01, 2014 4:28 pm

Re: Remote command execution failed: Host key verification f

Post by danoreilly »

Yes. I have no problem doing it from the command lines (even executing the Nagios commands on the remote node).
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Remote command execution failed: Host key verification f

Post by eloyd »

"Host key verification failed" is a very specific error in SSH. It means that the host key of the remote host was changed. Ssh stores the host keys of the remote hosts in ~/.ssh/known_hosts. Are you SURE you're becoming the nagios user and using it's .known_hosts file:

Code: Select all

(root)# su - nagios
(nagios)$ ssh <host> uptime
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Remote command execution failed: Host key verification f

Post by slansing »

@danoreilly, please let us know when you've got some updates to Eloyd's questions, thank you!
danoreilly
Posts: 28
Joined: Mon Dec 01, 2014 4:28 pm

Re: Remote command execution failed: Host key verification f

Post by danoreilly »

As I've stated at twice in this thread, I can ssh just fine:

# su - nagios
[nagios@tadmin03 ~]$ ssh ubdepot uptime
10:03:33 up 30 days, 2:25, 0 users, load average: 0.08, 0.03, 0.05
[nagios@tadmin03 ~]$
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Remote command execution failed: Host key verification f

Post by eloyd »

Yes, but we have to double check. :-)

Can you confirm that Nagios software is running as the nagios user?
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Remote command execution failed: Host key verification f

Post by abrist »

eloyd wrote:Can you confirm that Nagios software is running as the nagios user?

Code: Select all

grep user /usr/local/nagios/etc/nagios.cfg
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.
danoreilly
Posts: 28
Joined: Mon Dec 01, 2014 4:28 pm

Re: Remote command execution failed: Host key verification f

Post by danoreilly »

[ADMIN root@tadmin03: /root]
# grep user /usr/local/nagios/etc/nagios.cfg
# considered to be sensitive (usernames, passwords, etc) can be
# This determines the effective user that Nagios should run as.
# You can either supply a username or a UID.
nagios_user=nagios
# by users, so it must be writeable by the user that the web server
# this data to determine the number of users running specific version of
# it calculates (those not explicitly specified by the user).
[ADMIN root@tadmin03: /root]

and yes, on the Nagios host server it's running as nagios.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Remote command execution failed: Host key verification f

Post by eloyd »

For fun, run these commands:

Code: Select all

(as root): su - nagios
$ rm ~/.ssh/known_hosts
$ ssh <hostname> uptime
(answer yes to storing the host key if it asks)
Then see if your check runs
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
Locked