0

I have a simple shell script that uses the killall command. I would like to run this command without needing to enter my password. I've brought up visudo and inserted the following line into it:

anthony localhost = (root) NOPASSWD: /usr/sbin/myscript

I close Terminal, reopen it, and issue my script command. I am immediately greeted with a prompt for my password.

What am I doing wrong? Is this the proper way to do this?

1
  • Are you typing sudo myscript? If you have edited the sudoers file correctly then you shouldn't need the sudo in front of it (and if you put it there, I think it will still prompt you for your password). if it's something somehow related to killall then I will undelete my answer, which turned out to be slightly irrelevant - though in principle killall shouldn't need root access, I think... Depends on what process you're killing, I guess.
    – Jez W
    Jul 9, 2013 at 14:19

1 Answer 1

1

replace localhost by your hostname or use ALL if your sudoers file is not dispatched on other hosts

anthony ALL= (root) NOPASSWD: /usr/sbin/myscript

edit:
Scripts can be tricked by environment parameters. It is more secure (and easier to use) to sudo the killall command into your script than to sudo the script itself. Full killall command with its parameters can be put into the sudoers file, limiting the sudo killall usage.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .