Create sudoers cmd for a normal user to execute a privileged cmd?

I have a simple user without privileges that I need him to execute a single command with privileges. that would be:
"echo ‘passwd’ | sudo - S asterisk - rx ‘sip show peers’ " or equivalent

but I don’t seem to find how to do it because looks like sudoers is only directory related, or am I missing something?

Please refer Here

Yeah, i was reading this exact topic, but it always gives me an error when i try to create a cmnd:

"Cmnd_Alias check asterisk = sudo - S asterisk - rx ‘sip show peers’ "
it gives me a syntax error

Did you try what was listed here?

How do I use sudo?

Give user rokcy access to halt/shutdown command and restart Apache web server.

First, Login as root user. Use visudo command edit the config file:
# visudo

Append the following lines to file:
rokcy localhost=/sbin/halt
rokcy dbserver=/etc/init.d/apache-perl restart

Save and close file .

Now rokcy user can restart Apache web server by typing the following command:
$ sudo /etc/init.d/apache-perl restart

In your case you’d add:

userName localhost=asterisk -rx 'sip show peers'

to the sudo config file.

i did, but it doesnt seem to work since its a path, do i need to create a script?
i tried but it still told me i dont have permission…

i tried like this:

Cmnd_Alias CHECKAST = /script/astscript.txt
Cmnd_Alias CHECKRISK = /sbin/asterisk -rx sip show peers’

monitor = (root) NOPASSWD: CHECKRISK
monitor = (root) NOPASSWD: /script/astscript.txt
monitor = (root) NOPASSWD: /sbin/asterisk -rx ‘sip show peers’
monitor = (root) NOPASSWD: CHECKAST

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.