What's the best way to get a cli result for a common user?


(Art) #1

I’m trying to make an app to keep checking my extensions, but i don’t have much experience in the programming/API/ area… so i tried to enable permissions for non-privileged user via sudoers but didn’t have that much luck.

(On the app, i managed to make an ssh connection run a command but using an elevated user and return the string (text) of the result so i can manipulate it anyway i want on C#, but doesn’t seem that safe)

so i was wondering how to get the results of an cli command on my software, do i use an API? do i only change permissions on sudoers? do i need to also change asterisk permissions or freepbx?
is there something easier or similar like this?


#2

What are you trying to check ? Qualify times ? UNREACHABLE extensions ?


#3

add to your non privileged sudoer user ‘unpriv’ with visudoer

unpriv ALL = (root) NOPASSWD: /usr/sbin/asterisk

Then things like

ssh unpriv@your.pbx "sudo  asterisk -x 'sip show peers'"

should work.


(Art) #4

only some like " asterisk -rx ‘sip show peers’ "


(Art) #5

that worked, but it would enable all asterisk commands right?
if i would only choose a few, I’d only add the command itself after it?


#6

No , you would have to wrap each ine allowed in to its own sript and allow those.


(system) closed #7

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