0

I have to execute a shell script as another user, but without be prompted for password.

I've edited the etc/sudoers file with visudo, adding the following line.

_www  localhost=(otheruser) NOPASSWD:/patho/to/my/script.sh

If I understand how sudo works, this means that user _www is allowed to execute like user 'otheruser', without be prompted for password, only from localhost.

is that correct?

the system continue to prompt for the password...

4
  • No, it means that the _www user can do /patho/to/my/script.sh, which is not enough. You should add /bin/sh to make it an executable command. All together, /bin/sh /patho/to/my/script.sh.
    – fedorqui
    Jan 10 '14 at 14:22
  • Thank you, but it still prompt me for the password Jan 10 '14 at 14:25
  • This question is off-topic here. If the question was about the script file itself, it would be appropriate, but you're asking about system configuration instead. Your question would be more suitable for Ask Ubuntu or Super User instead.
    – Ken White
    Jan 10 '14 at 14:34
  • Ok, I will ask to the right place. Thank you. Jan 10 '14 at 16:29
0

Looks right to me. Sudoer rules at the bottom override rules above. Do you possibly have another below it? Sudoers rules are interpreted in order. A rule at the bottom will override a conflicting rule above it. Make sure you don't have an other policy overriding it below.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.