2

I need to run a script with sudo without entering my password. I'm editing /etc/sudoers (using sudo visudo) and on the last line, I'm adding:

MY-USER-NAME ALL=(ALL) NOPASSWD:ALL

I just want to make sure that it works before specifying a script to disable sudo access. However whatever sudo command I run still needs me to enter a password. What am I doing wrong here? Could it be that /etc/sudoers is being overwritten somewhere else I'm not aware about?

4
  • In all the examples I have seen NOPASSWD: had a blank before the ALL like NOPASSWD: ALL. Reboot to check.
    – harrymc
    Commented Sep 4, 2021 at 7:48
  • that's a very good point. I'll try it to make sure. I did other changes (password expiration time) that took effect immediately. Is rebooting really necessary?
    – Amir
    Commented Sep 4, 2021 at 7:52
  • Not if it works without boot.
    – harrymc
    Commented Sep 4, 2021 at 7:53
  • This is baaaaad. That space did the job. Thanks a bunch for your help. Can you make it a post with a little info the format of the line so that I can select it as the right answer? The formatting was one of the things I missed big time.
    – Amir
    Commented Sep 4, 2021 at 7:58

1 Answer 1

1

The sudoers(5) man-page specifies:

Multiple arguments may be specified, separated by white space.

What is missing is the little white space after the NOPASSWD:, to separate it from the next argument:

MY-USER-NAME ALL=(ALL) NOPASSWD: ALL

You must log in to answer this question.

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