How can passwordless sudo
access be setup on either RHEL (Fedora, CentOS, etc) or Ubuntu distributions? (If it's the same across distros, that's even better!)
Setting: personal and/or lab/training equipment with no concern for unauthorized access (ie, the devices are on non-public networks, and any/all users are fully trusted, and the contents of the devices are "plain-vanilla").
EDIT thanks to medina's comment: According to the man page, you should be able to write
to allow all users to run all commands without a password.
For reference, I'm leaving my previous answer:
If you add a line of the form
to
/etc/sudoers
(using thevisudo
command, of course), it will let everyone in the groupwheel
run any commands without providing a password. So I think the best solution is to put all your users in some group and put a line like that insudoers
- obviously you should replacewheel
with the actual group you use.Alternatively, you can define a user alias,
and use that:
although you would have to update
/etc/sudoers
every time you add or remove a user.I tried the solutions above to no avail. The following solution worked for me Edit the /etc/sudoers file and add the following line
The key is to add it after the last line which says
I tried all the answers on this page, with no useful results. Eventually I figured it out, use this command to list your sudo rights:
This should give you an output like this:
It shows that I'm configured with root privileges but that I'm still part of a group (admin) matched to a sudo rule which expects the password ("(ALL) ALL"). This was forcing sudo to prompt me. The rule in question was the admin users:
Once I commented this out, I was able to sudo without password. I hope this is of use to someone else.
Within
/etc/sudoers
there's an example of just that towards the bottom of the file:There is another way to do it without touching the sudoers file.
Edit
/etc/pam.d/su
and uncomment the line below:Add the user to the
wheel
group.This is an old thread, but it's interesting that no one has added the system default
authenticate
to this answer list. Using an entry ofIn the sudoers file would allow any user to use their defined
sudo
commands without any password authentication. It's part of the default sudo specification and is portable across all platforms, as specified in the OP. And, if you need to scope it to a specific user, tryThere is another way to do it without touching the sudoers file.
Edit
/etc/pam.d/sudo
and add the line below:Add the user to the
wheel
group.Props to "topdog" and "Daniel Serodio" for the original answer with regard to "su" rather than "sudo". I used that as a reference and shamelessly copied, and amended, their post.
reopen terminal, verify that you are not asked for your password: