I'm trying to allow a specific user to run a specific command with sudo but not be prompted for a password in CentOS 7. So I've used visudo
tried added the following line as both the 1st and last line in the file
testuser ALL=(ALL) NOPASSWD: /home/testuser/script.sh
I've also tried
testuser ALL= NOPASSWD: /home/testuser/script.sh
then, as root, I run su -u testuser
to switch to the user and then sudo ./script.sh
and sudo /home/testuser/script.sh
and am still prompted for a password. Is there something else I need to do to allow running this script without a password?
/home/testuser/script.sh
, you aren't running the script, you are running the shell (e.g.bash
) and passing the script as an argument to the shell.