sudo prompts for password over ssh
Posted
by
Joe Watkins
on Server Fault
See other posts from Server Fault
or by Joe Watkins
Published on 2012-06-27T16:01:04Z
Indexed on
2012/06/28
15:18 UTC
Read the original article
Hit count: 257
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
© Server Fault or respective owner