Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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