How to setup passwordless sudo (the right way)

As root:

groupadd passwordless
usermod -aG passwordless yourusername
echo "%passwordless ALL=(ALL:ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/passwordless > /dev/null
chmod 440 /etc/sudoers.d/passwordless
visudo -c

Why you should use this method:

  1. Using this method gives you control over who has passwordless sudo privileges
  2. Passwordless sudo privileges can be removed by simply removing a user from the group
  3. This uses /etc/sudoers.d which survives system upgrades
  4. /etc/sudoers.d doesn’t require the use of visudo making scripting easy

To remove passwordless privileges:

gpasswd -d {your_username_here} passwordless