20

My Problem

I would like to be able to run sudo commands on MacOS Sierra 10.12 without having to type a password.

What have I tried

I've read the following:

And changed the relevant part of my /etc/sudoers file to:

root ALL=(ALL) ALL
%admin  ALL=(ALL) NOPASSWD: ALL
%wheel ALL=(ALL) NOPASSWD: ALL
%wheel ALL=(ALL) NOPASSWD: ALL
%sudo   ALL=(ALL) NOPASSWD: ALL
adamatan ALL=(ALL) NOPASSWD: ALL

My local user id (whoami) is adamatan.

I'm still being asked to type a password every few minutes when calling sudo. Any idea what's wrong?

  • Does sudo -i work on Sierra? In El Cap it will switch you to root context and run login resource files for that session. (Will still need to be sudoers, so earlier effort not wasted). – FiddleDeDee Oct 27 '16 at 13:12
  • Works, but how does it solve the problem? – Adam Matan Oct 30 '16 at 10:15
  • 1
    I just recently upgraded to Sierra and ran into this. The default /etc/sudoers file has changed fairly radically from El Cap. There I just dropped a one line config file into the sudoers.d directory and it "just worked". Seems things have changed. I'll report back if I get anymore info. – Mark Edington Jul 12 '17 at 4:02
  • Maybe just execute one of the macOS root permissions exploits instead ;) – sudo Jul 19 '18 at 18:10
  • That defeats the whole point of sudo – Matthew Barclay Jun 14 at 3:05
22

Open a terminal, run sudo visudo

Edit the line:

%admin ALL=(ALL) ALL

To say:

%admin ALL=(ALL) NOPASSWD: ALL

Now, you should now be able to run sudo without password.

  • 1
    reboot it not really needed – ecerulm Dec 6 '18 at 13:18
2

Try setting NOPASSWD on the root user. In /etc/sudoers

root            ALL = (ALL) NOPASSWD: ALL
2
root ALL=(ALL) ALL
%admin ALL=(ALL) NOPASSWD: ALL

stens ALL = (ALL) NOPASSWD: ALL # my userid is stens

You must log in to answer this question.

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