SSH Check monitor fails, but works manually via CLI

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.
Locked
aylesworth
Posts: 31
Joined: Mon Mar 22, 2021 12:57 pm

SSH Check monitor fails, but works manually via CLI

Post 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!
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

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

Post 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
aylesworth
Posts: 31
Joined: Mon Mar 22, 2021 12:57 pm

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

Post 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!
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

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

Post 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.
Locked