linux:sudo-without-pw

Allow sudo without password for users and groups

sudo is a program that allows a user to run programs with the security privileges of another user. If no user is specified, it will try to run the other program as root, or the superuser. By default, running sudo will prompt for the superuser password, as in the following example;

michael@admin-server:~$ sudo vim /etc/resolv.conf

 We assume you have received the usual lecture from the local System
 Administrator. It usually boils down to these three things:

 #1) Respect the privacy of others.
 #2) Think before you type.
 #3) With great power comes great responsibility.

 Password:

While this is good for security reason, normal users would want to avoid the password prompt completely, especially if they are just running it on a desktop.

To enable passwordless sudo, you need to edit the /etc/sudoers file or like me create an new file in the location /etc/sudoers.d/ . This can be done by directly editing/creating the file using your favorite editor as the following;

# vim /etc/sudoers.d/blacknet_sudo_rules

In the file, there are 2 options to enable passwordless sudo, which is to allow by group, or by user.

To everyone in the group blackGATEadmins to be able to use sudo without password, add the following line;

%blackGATEadmins ALL=NOPASSWD: ALL

Adding the following line will allow the user michael to use sudo without password

michael ALL=NOPASSWD: ALL
#...

  • linux/sudo-without-pw.txt
  • Last modified: 2019/03/07 14:06
  • by michael