I have a /etc/sudoers.d file which I want to run a program (asterisk) WITH arguments as a user (zabbix). So far I have tried:
zabbix ALL = NOPASSWD: /etc/path/to/my/script.sh
And
zabbix ALL=(ALL) NOPASSWD: /etc/path/to/my/script.sh
which all the script does is run sudo /usr/sbin/asterisk -rx "pjsip show channelstats"
. I've tried to run this command directly in the sudoers file but even when it then looks like.
zabbix ALL=(ALL) NOPASSWD: /usr/sbin/asterisk -rx "pjsip show channelstats"
And I've also tried escaping the quotes with no luck, which looks like.
zabbix ALL=(ALL) NOPASSWD: /usr/sbin/asterisk -rx \\"pjsip show channelstats\\"
It still asks me for a password. even when I change ALL params to the user 'asterisk' or even 'root' it still asks for a password. When I goto Zabbix (Monitoring Server) and try to retrive said data it get this error message.
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
How ever I can get it to work if I just give it the executable, just not with the params which having access to Asterisk without any specific params is a really REALLY bad practise. How can I make it not ask for the password?
P.S I'm always using Visudo for editing the Sudoers file/s.
Thanks.