Remote command execution failed: Permission denied,please...

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.
rajesh.mehra
Posts: 35
Joined: Mon Jan 27, 2014 2:38 am
Location: New Delhi, India

Re: Remote command execution failed: Permission denied,pleas

Post by rajesh.mehra »

Please check these values also.

Code: Select all

[root@localhost etc]# cat nagios.cfg | grep nagios_user
nagios_user=nagios
[root@localhost etc]# cat nagios.cfg | grep nagios_group
nagios_group=nagios
aleks1
Posts: 43
Joined: Thu Nov 28, 2013 1:33 pm

Re: Remote command execution failed: Permission denied,pleas

Post by aleks1 »

this is wrong see the answer below :)

Code: Select all

root@maestro:/usr/lib/nagios/plugins# cat nagios.cfg | grep nagios_user
cat: nagios.cfg: No such file or directory
root@maestro:/usr/lib/nagios/plugins# cat nagios.cfg | grep nagios_group
cat: nagios.cfg: No such file or directory
root@maestro:/usr/lib/nagios/plugins# 
i think because this nagios was implemented ( not by me :) ) with root user!
Last edited by aleks1 on Thu Jun 12, 2014 5:27 am, edited 1 time in total.
aleks1
Posts: 43
Joined: Thu Nov 28, 2013 1:33 pm

Re: Remote command execution failed: Permission denied,pleas

Post by aleks1 »

Ops! my stupid error! i was in the wrong directory! :)
in the right directory:

Code: Select all

root@maestro:/etc/nagios3# cat nagios.cfg | grep nagios_user
nagios_user=nagios
root@maestro:/etc/nagios3# cat nagios.cfg | grep nagios_group
nagios_group=nagios
Last edited by aleks1 on Thu Jun 12, 2014 5:41 am, edited 1 time in total.
rajesh.mehra
Posts: 35
Joined: Mon Jan 27, 2014 2:38 am
Location: New Delhi, India

Re: Remote command execution failed: Permission denied,pleas

Post by rajesh.mehra »

check nagios user is available in your system ???

Code: Select all

[root@localhost ~]# id nagios
uid=494(nagios) gid=490(nagios) groups=490(nagios)
If available
then
Switch to nagios user and run command by nagios user.

Code: Select all

[root@localhost ~]# su - nagios
[nagios@localhost]$ /usr/lib/nagios/plugins/check_by_ssh -4 -H remote address -l root -p 2022 -C "/usr/local/nagios/libexec/check_nagios -t 20 -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios" -vvvvvvvvvvvvvvvvvvvvv
else

add nagios user in system
aleks1
Posts: 43
Joined: Thu Nov 28, 2013 1:33 pm

Re: Remote command execution failed: Permission denied,pleas

Post by aleks1 »

check nagios user is available in your system ???

Code: Select all

root@maestro:/etc/nagios3# id nagios
uid=121(nagios) gid=124(nagios) groups=124(nagios)
is available?
Switch to nagios user and run command by nagios user.

Code: Select all

root@maestro:/etc/nagios3# su - nagios
root@maestro:/etc/nagios3# su - nagios
root@maestro:/etc/nagios3# su - nagios
i can't switch to nagios user!

i must create a nagios user?

because this nagios (implemented not by me) have a lot of service and hosts to other remote servers.... if i create nagios user... could cause problems to other remote servers?
rajesh.mehra
Posts: 35
Joined: Mon Jan 27, 2014 2:38 am
Location: New Delhi, India

Re: Remote command execution failed: Permission denied,pleas

Post by rajesh.mehra »

Hi

You dont need to create nagios user It is already on your system. If you will switch to nagios user it will not effect your system.
because all commands are running by nagios in backend not by root.

Switch to nagios user then run the command I hope it will show exact problem
Stuart Watts
Posts: 40
Joined: Wed Sep 25, 2013 7:01 am

Re: Remote command execution failed: Permission denied,pleas

Post by Stuart Watts »

Forums ate my response... :evil:

The clue is in the error message "Port must be a positive integer" ;)

The problem is the service definition - $ARG1$ is passing "2022" to the command, which is used as the value for the option -H, which should be the host address or name. You're passing "root" as $ARG2$ which is sent to the plugin as the value for -p, hence the error message.

Update your service definition to:

Code: Select all

    define service {
            use generic-service
            host_name backups
            service_description Nagios Status
            check_command check_nagios_ssh!$HOSTADDRESS$!2022!root!"/usr/local/nagios/libexec/check_nagios -t 20 -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios"
    }
rajesh.mehra
Posts: 35
Joined: Mon Jan 27, 2014 2:38 am
Location: New Delhi, India

Re: Remote command execution failed: Permission denied,pleas

Post by rajesh.mehra »

Thanks Stuart Watts

:( Exactly right

Change command definition according to below

Code: Select all

define command{
command_name check_nagios_ssh
command_line /usr/lib/nagios/plugins/check_by_ssh -H $HOSTADDRESS$ -p $ARG1$ -l $ARG2$ -C $ARG3$
}
OR
Stuart Watts wrote:Forums ate my response... :evil:

The clue is in the error message "Port must be a positive integer" ;)

The problem is the service definition - $ARG1$ is passing "2022" to the command, which is used as the value for the option -H, which should be the host address or name. You're passing "root" as $ARG2$ which is sent to the plugin as the value for -p, hence the error message.

Update your service definition to:

Code: Select all

    define service {
            use generic-service
            host_name backups
            service_description Nagios Status
            check_command check_nagios_ssh!$HOSTADDRESS$!2022!root!"/usr/local/nagios/libexec/check_nagios -t 20 -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios"
    }

both are correct
rajesh.mehra
Posts: 35
Joined: Mon Jan 27, 2014 2:38 am
Location: New Delhi, India

Re: Remote command execution failed: Permission denied,pleas

Post by rajesh.mehra »

Come to the previous error


Give access to nagios user so that it can login to root@remote.server without password. Still it can login by root.


aleks1 wrote:Hi everybody! :)

I'm trying to implement a remote command from a nagios (let's call it for convenience nagios A :)) to the new nagios on ubuntu server 12.04 lts (nagios B) (this nagios on ubuntu server , was done , with the precious help of this forum :))
anyway i want to implement a simple command that control my nagios.log (on remote server nagios B)
i have just put the public key in authorized_keys.... and the access without password... works! the nagiosA access to the nagiosB only with a specific port:

Code: Select all

ssh -p 2022 root@intranet.xx.xx
then i have tried the command from the command line:

Code: Select all

root@maestro: root@maestro:/etc/nagios-plugins/config# /usr/lib/nagios/plugins/check_by_ssh  -H 'intranet.xx.xx' -p '2022'  -C "/usr/local/nagios/libexec/check_nagios -F '/usr/local/nagios/var/nagios.log' -e '5' -C '/usr/local/nagios/bin/nagios'"

NAGIOS OK: 40 processes, status log updated 47 seconds ago 
ok works!
but when i try to implement this command on servece definition (for control automatically the remote nagios.log)
i got this error:

Code: Select all

backups;Nagios Status;UNKNOWN;SOFT;2;Remote command execution failed: Permission denied, please try again.
where am i wrong?

this is my command definition:

Code: Select all

define command{
        command_name    check_nagios_ssh
        command_line    /usr/lib/nagios/plugins/check_by_ssh -H '$HOSTADDRESS$' -p '$ARG4$' -C "/usr/local/nagios/libexec/check_nagios -F '$ARG1$' -e '$ARG2$' -C '$ARG3$'"
        }
this is my service definition:

Code: Select all

define service {
        use                     generic-service
        host_name               backups
        service_description     Nagios Status
        check_command           check_nagios_ssh!/usr/local/nagios/var/nagios.log!5!/usr/local/nagios/bin/nagios!2022
}
this is my host definition:

Code: Select all

define host{
        use                     generic-host            ; Name of host template to use
        host_name               backups
        alias                   Server Nagios
        address                 intranet.xx.xx
        }

any help be appreciate!!! :)
aleks1
Posts: 43
Joined: Thu Nov 28, 2013 1:33 pm

Re: Remote command execution failed: Permission denied,pleas

Post by aleks1 »

hi everybody and thanks for support! :) (
Forums ate my response...
why forums ate your response? hehehe :) )
with this service definition:

Code: Select all

    define service {
            use generic-service
            host_name backups
            service_description Nagios Status
            check_command check_nagios_ssh!$HOSTADDRESS$!2022!root!"/usr/local/nagios/libexec/check_nagios -t 20 -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios"
    }
and this command definition:

Code: Select all

define command{
command_name check_nagios_ssh
command_line /usr/lib/nagios/plugins/check_by_ssh -H $ARG1$ -p $ARG2$ -l $ARG3$ -C $ARG4$
}
i got this error:

Code: Select all

SERVICE ALERT: backups;Nagios Status;UNKNOWN;SOFT;1;Remote command execution failed: Permission denied, please try again.
with this service definition:

Code: Select all

define service {
        use generic-service
        host_name backups
        service_description Nagios Status
        check_command check_nagios_ssh!2022!root!"/usr/local/nagios/libexec/check_nagios -t 20 -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios"
}
and with command definition:

Code: Select all

define command{
command_name check_nagios_ssh
command_line /usr/lib/nagios/plugins/check_by_ssh -H $HOSTADDRESS$ -p $ARG1$ -l $ARG2$ -C $ARG3$
}
i got this errorr:

Code: Select all

SERVICE ALERT: backups;Nagios Status;UNKNOWN;SOFT;2;Remote command execution failed: Permission denied, please try again.
Switch to nagios user then run the command I hope it will show exact problem
but i can't switch to nagios user!!! :(

Code: Select all

root@maestro:/etc/nagios3# id nagios
uid=121(nagios) gid=124(nagios) groups=124(nagios)
but when i try...su -nagios :

Code: Select all

root@maestro:/etc/nagios3# su - nagios
root@maestro:/etc/nagios3# su - nagios
root@maestro:/etc/nagios3# su - nagios
i'm little bit confused! help!
Locked