check_by_ssh works fine on cli, but not in UI
Posted: Sat Aug 09, 2014 4:27 pm
Hello.
We're using Nagios XI 2014R1.1 on CentOS 6.5.
I have a couple of remote boxes I need to monitor over an ssh tunnel. Had no problems making that happen with VMWare hosts; however, using the check_by_ssh plugin is giving some trouble in the UI. It is working fine on the command line.
CLI
[root@nagios libexec]# su - nagios -c '/usr/local/nagios/libexec/check_by_ssh -H localhost -i /home/nagios/.ssh/id_rsa -l root -p 32222 -C "/usr/local/bin/check_disk -w 20% -c 10% -p /home" -E'
DISK OK - free space: /home 318081 MB (79% inode=99%);| /home=83669MB;338600;380925;0;423251
Test from UI - note....I added .ssh to /var/www just to see what happened. No key is in there. It's like apache is trying to set up
Testing check from command line...
COMMAND: /usr/local/nagios/libexec/check_by_ssh -H localhost -i /home/nagios/.ssh/id_rsa -l root -p 32222 -C "check_disk -w 20% -c 10% -p /home"
OUTPUT: Remote command execution failed: Failed to add the host to the list of known hosts (/var/www/.ssh/known_hosts).
I went ahead and opened the permissions up on /var/www/.ssh/ and let apache make the known_hosts file and ran the test again.
Testing check from command line...
COMMAND: /usr/local/nagios/libexec/check_by_ssh -H localhost -i /home/nagios/.ssh/id_rsa -l root -p 32222 -C "check_disk -w 20% -c 10% -p /home"
OUTPUT: Remote command execution failed: Permission denied, please try again.
One more time from the CLI.....
[root@nagios libexec]# su - nagios -c '/usr/local/nagios/libexec/check_by_ssh -H localhost -i /home/nagios/.ssh/id_rsa -l root -p 32222 -C "/usr/local/bin/check_disk -w 20% -c 10% -p /home"'
DISK OK - free space: /home 318081 MB (79% inode=99%);| /home=83669MB;338600;380925;0;423251
[root@nagios libexec]#
Since keys are involved here, I'd rather not run this command as apache.
I set StrictHostKeyChecking no in /etc/ssh/ssh_config even though it was fine on the CLI, and it moved me from an earlier error to the one I'm getting now.
What am I missing here.
Thanks a million.
PS....I tried again adding the full path to the UI but it still didn't work.
Testing check from command line...
COMMAND: /usr/local/nagios/libexec/check_by_ssh -H localhost -i /home/nagios/.ssh/id_rsa -l root -p 32222 -C "/usr/local/bin/check_disk -w 20% -c 10% -p /home"
OUTPUT: Remote command execution failed: Permission denied, please try again.
We're using Nagios XI 2014R1.1 on CentOS 6.5.
I have a couple of remote boxes I need to monitor over an ssh tunnel. Had no problems making that happen with VMWare hosts; however, using the check_by_ssh plugin is giving some trouble in the UI. It is working fine on the command line.
CLI
[root@nagios libexec]# su - nagios -c '/usr/local/nagios/libexec/check_by_ssh -H localhost -i /home/nagios/.ssh/id_rsa -l root -p 32222 -C "/usr/local/bin/check_disk -w 20% -c 10% -p /home" -E'
DISK OK - free space: /home 318081 MB (79% inode=99%);| /home=83669MB;338600;380925;0;423251
Test from UI - note....I added .ssh to /var/www just to see what happened. No key is in there. It's like apache is trying to set up
Testing check from command line...
COMMAND: /usr/local/nagios/libexec/check_by_ssh -H localhost -i /home/nagios/.ssh/id_rsa -l root -p 32222 -C "check_disk -w 20% -c 10% -p /home"
OUTPUT: Remote command execution failed: Failed to add the host to the list of known hosts (/var/www/.ssh/known_hosts).
I went ahead and opened the permissions up on /var/www/.ssh/ and let apache make the known_hosts file and ran the test again.
Testing check from command line...
COMMAND: /usr/local/nagios/libexec/check_by_ssh -H localhost -i /home/nagios/.ssh/id_rsa -l root -p 32222 -C "check_disk -w 20% -c 10% -p /home"
OUTPUT: Remote command execution failed: Permission denied, please try again.
One more time from the CLI.....
[root@nagios libexec]# su - nagios -c '/usr/local/nagios/libexec/check_by_ssh -H localhost -i /home/nagios/.ssh/id_rsa -l root -p 32222 -C "/usr/local/bin/check_disk -w 20% -c 10% -p /home"'
DISK OK - free space: /home 318081 MB (79% inode=99%);| /home=83669MB;338600;380925;0;423251
[root@nagios libexec]#
Since keys are involved here, I'd rather not run this command as apache.
I set StrictHostKeyChecking no in /etc/ssh/ssh_config even though it was fine on the CLI, and it moved me from an earlier error to the one I'm getting now.
What am I missing here.
Thanks a million.
PS....I tried again adding the full path to the UI but it still didn't work.
Testing check from command line...
COMMAND: /usr/local/nagios/libexec/check_by_ssh -H localhost -i /home/nagios/.ssh/id_rsa -l root -p 32222 -C "/usr/local/bin/check_disk -w 20% -c 10% -p /home"
OUTPUT: Remote command execution failed: Permission denied, please try again.