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

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/redirect.sh 8892 8893

Therefore I added this in visudo :

apache ALL=(hremotessh) NOPASSWD: /home/hremotessh/scripts/redirect.sh

But sudo is still asking the password ?

sudo /home/hremotessh/scripts/redirect.sh
[sudo] password for apache:

I tried this, but not better :

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

Any idea would be warmly welcomed :-)

Denis

share|improve this question
1  
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

1 Answer 1

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/redirect.sh 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 redirect.sh 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/redirect.sh 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/redirect.sh ! Thanks a lot everyone for your help ! –  db_ch Jul 21 '14 at 14:02

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.