Page 1 of 1

SSH Check monitor fails, but works manually via CLI

Posted: Mon Jul 12, 2021 1:54 pm
by aylesworth
Hello,

We have an SSH check that runs a remote script checking the license count for an application. When running the check via the actual service monitor, I get this result (I've changed IP information below):

[nagios@nagiosxi ~]$ /usr/local/nagios/libexec/check_by_ssh -H [IP HERE] -C "~/check_ud.sh"
Remote command execution failed: Permission denied, please try again.

If I log into the server itself, and su - nagios from the root, running the same command, I get the expected output:
[nagios@nagiosxi ~]$ /usr/local/nagios/libexec/check_by_ssh -H [IP HERE] -C "~/check_ud.sh"
Password:
OK - 341 is 71% of 478 Unidata Licenses used.|unidata=71%;90;95

It seems like the keypair/fingerprint is not present, but I've added that both via the IP and the hostname to known_hosts. I've also created a keypair on the nagios server itself and added the public key to the monitoring endpoint server.

What am I missing?

Thanks!

Re: SSH Check monitor fails, but works manually via CLI

Posted: Mon Jul 12, 2021 2:37 pm
by pbroste
Hello aylesworth,

Please check the permissions and ownership on your "~/check_ud.sh" script. should be:

Code: Select all

chown nagios:nagios  ~/check_ud.sh
and

Code: Select all

chmod 755 ~/check_ud.sh
Thanks,
Perry

Re: SSH Check monitor fails, but works manually via CLI

Posted: Mon Jul 12, 2021 4:40 pm
by aylesworth
Hi Perry,

Thanks for the suggestion, not sure what happened but re-issuing the keypair and re-adding that to the host fixed the issue.

This can be closed!

Re: SSH Check monitor fails, but works manually via CLI

Posted: Tue Jul 13, 2021 10:36 am
by gormank
Have you tried to ssh to the remote host as nagios from the nagios host? If it prompts for a password, something in the ssh setup probably needs fixed.