What I need:
- be able to execute
any executablewith a
sudowith a password prompt
- be able to execute one executable,
/home/username/script.sh, without a password prompt.
When I configure like this
username ALL=(ALL) NOPASSWD: /home/username/script.sh
I have the desired effect on the
script.sh, but I cannot execute any other
$ sudo ./script.sh # runs fine!
Attempt something other
$ sudo nano /etc/sudoers [sudo] password for username: Sorry, user username is not allowed to execute '/usr/bin/nano /etc/sudoers' as root on hostname.
Seems this is a result of replacing
NOPASSWD, and seems I need both.
sudoers file has
ALL for the user, I can execute whatever I want with password prompt
username ALL=(ALL) ALL
I tried to combine ALL and NOPASSWD but had no results
username ALL=(ALL) ALL, NOPASSWD: /home/username/script.sh
Like this it asks for password for
Can I have both?