I'm sorry if I missed an answer here. But I did Google this and couldn't find a straight forward answer.

I want to enable the apache user to run commands as another user, but when I do:

echo "PASSWORD" | sudo -u another_user -S echo "X"

Inside a PHP script, I get:

[sudo] password for apache:

The apache user doesn't have a password, so I can't just output it in order to run sudo. Any way I can enable the apache user to run sudo for a specific set of commands under the another_user account without a password?

PS.: I currently have

apache ALL=(yourhost) /usr/bin/git --git-dir=/* --work-tree=/* pull origin master

on my sudoers file.


lookup up "NOPASSWD" usage in the sudoers file.

as in:

apache ALL=(yourhost) NOPASSWD:/usr/bin/git --git-dir=/* --work-tree=/* pull origin master

Whether this is a good idea or not, is a different discussion.

| improve this answer | |
  • Yeah, I know it isn't exactly the safest thing in the world, but at least i'm narrowing the NOPASSWD to only 1 very specific command. Thanks! – dmmd Aug 5 '12 at 23:48

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.