I have a script that logs into a remote host via ssh -t
and uses sudo service foo restart
.
The requirement is to avoid the prompt for a password on the remote host. The remote host authenticates via SSH certificate. The sudoers
file on the remote host allows that user to execute the service command with NOPASSWD
.
However, during my tests, I'm prompted for a password and this is unacceptable. If I run this manually without the -t
flag, it works. However the -t
flag throws everything off.
Is there a way around this?
auth.log
orsecure
in/var/log
. – jordanm Jun 26 '13 at 02:10NOPASSWD
is set? Remember that only the last match insudoers
counts. Also remember that ifsudo
doesn't prompt you for a password, it can be because of the cache, so make sure to flush it before each test withsudo -k
. – Gilles 'SO- stop being evil' Jun 26 '13 at 23:39NOPASSWD
line? Why is-t
needed? Another option is to create a key for just that command, going directly to root , and use thecommand=""
parameter in theauthorized_keys
file. (passswordless SSH keys allowing for a full root login can be a huge security risk...) – Gert van den Berg Nov 02 '16 at 09:29