sudo prompts for password over ssh
- by Joe Watkins
I have sudo set up for a shell script as follows on "hostname" (sudo -l output):
(suser) NOPASSWD: /path/script*
sudoers content is:
myuser ALL=(suser) NOPASSWD: /path/script*
this works fine, so I can run the following, logged in locally on hostname, without need for password:
sudo -u suser /path/script
however, when I use ssh (with keys set up, so no password require) 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.
Why?
NB the following does not prompt for password at any point:
$ ssh hostname
$ sudo -u suser /path/script