I wrote a Nagios check script which checks if user peeradmin is able to touch a file in some mount on the server.
Nagios user is: nagios .
I've edited /etc/sudoers
and added these lines but none worked:
nagios ALL=NOPASSWD: /bin/su - peeradmin -c /bin/touch
nagios ALL=(peeradmin) NOPASSWD: /bin/su
nagios ALL=(peeradmin) NOPASSWD: /bin/su - peeradmin
But still, while logged in as nagios user i'm unable to run any command as user peeradmin without being asked for a password:
[nagios@hadoop-nn1 ~]$ su - peeradmin -c "ls"
Password:
What am I doing wrong and how can I allow user nagios to run commands as user peeradmin?
Thanks in advance,