Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I read all sudo posts on serverfault, but I still cannot figure out what I'm doing wrong. Normally I finally find the solution but not this time :

I want apache user to be able to execute this command as user "hremotessh" :

sudo /home/hremotessh/scripts/ 8892 8893

Therefore I added this in visudo :

apache ALL=(hremotessh) NOPASSWD: /home/hremotessh/scripts/

But sudo is still asking the password ?

sudo /home/hremotessh/scripts/
[sudo] password for apache:

I tried this, but not better :

sudo -u hremotessh /home/hremotessh/scripts/
hremotessh is not in the sudoers file.  This incident will be reported.

Any idea would be warmly welcomed :-)


share|improve this question
Did you definitely run the second sudo command as apache? – Flup Jul 21 '14 at 10:59
Flup, yes, at least I'm amost sure, I did the following from root : su - apache -s /bin/bash – db_ch Jul 21 '14 at 11:12
you may find some info in /var/log/secure , did you check ? – tonioc Jul 21 '14 at 11:40
db_ch, re Flup's comment, try again. That error message strongly suggests you were the hremotessh user at the time. – MadHatter Jul 21 '14 at 11:55
What is the best way to be sure who I am logged in under ? At least what sudo is taking into account ? – db_ch Jul 21 '14 at 13:58
up vote 4 down vote accepted

Unless you want to run the command as root you need to specify the username, so

 su - apache -s /bin/bash 
 sudo -u hremotessh /home/hremotessh/scripts/ 8892 8893

is the correct syntax to test the sudo command.

Since you're not prompted for the apache user's password sudo seems to be configured correctly.

The resulting warning: hremotessh is not in the sudoers file. indicates that another sudo command is used in the script. And there's no (valid) sudo policy for that user.

share|improve this answer
HBruijn makes a good point (+1 from me). db_ch, could you edit the /home/hremotessh/scripts/ script into your question? – MadHatter Jul 21 '14 at 11:56
Yes !!! Congratulations to HBruijn, stupid of me, I forgot to remove the sudo from /home/hremotessh/scripts/ ! Thanks a lot everyone for your help ! – db_ch Jul 21 '14 at 14:02

Your Answer


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.