Running sudo when user has blank password?

I have a user with a blank password, but now I can't run sudo with that account.

sudo ls
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
sudo: 3 incorrect password attempts

Is there any way around this?


Solution 1:

sudo on macOS requires the account to have a password:

https://support.apple.com/en-us/HT202035

Therefore it is not possible to just press ENTER to continue at the prompt, like you would expect from some other systems.

This behaviour is enforced through a configuration of the PAM subsystem. You can change the settings for that in /etc/pam.d, where you have a sudo file that setups the authentication requirements for the sudo command.

WARNING: Changing the contents of the files in /etc/pam.d incorrectly can deny you from logging to your system at all. Only make changes if you know what you're doing, you have a backup - and you feel confident in booting in Recovery mode to undo your changes if it should fail.