Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have sudo set up for a user (myuser) as follows on "hostname" (sudoers content):

myuser ALL=(suser) NOPASSWD: /path/script*

this works fine, so I can run the following, logged in locally as myuser on hostname, without need for password:

sudo -u suser /path/script

however, when I use ssh (with keys set up, so no password required) to login and run, as follows:

ssh hostname sudo -u suser /path/script 

I get prompted for a password, and when the password is entered I get:

Sorry, user myuser is not allowed to execute '/path/script' as suser on hostname
.

UPDATE The problem is solved by removing the "*" from the end of the command in sudoers. The * was added to allow parameters to be passed to script, but actually doesn't appear to be necessary. Still don't understand why the * allows the sudo to work locally, but not over ssh. So question still stands

share|improve this question
    
Difficult to answer without the content of /etc/sudoers and /etc/ssh/sshd-config but are you sure, ssh is not asking for the password? –  Fra Orolo Jun 27 '12 at 16:00
    
I can't see /etc/sudoers, but sudo -l gives the output shown ssh hostname logs in with no password prompt, so I was assuming that's OK. I don't have /etc/ssh/sshd-config - is there an alternative? and how might it affect this? –  Joe Watkins Jun 27 '12 at 16:02
    
Does reserving a pseudo pty change anything, ie. ssh -t hostname sudo -u user /path/script –  Thor Jun 27 '12 at 16:25
    
no, that doesn't help –  Joe Watkins Jun 27 '12 at 16:38
    
Show us what you can from: ssh hostname sudo -D9 -u user /path/script. –  Thor Jun 27 '12 at 16:45

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.