1

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

8
  • 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, 2012 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? Jun 27, 2012 at 16:02
  • Does reserving a pseudo pty change anything, ie. ssh -t hostname sudo -u user /path/script
    – Thor
    Jun 27, 2012 at 16:25
  • no, that doesn't help Jun 27, 2012 at 16:38
  • Show us what you can from: ssh hostname sudo -D9 -u user /path/script.
    – Thor
    Jun 27, 2012 at 16:45

0

You must log in to answer this question.

Browse other questions tagged .