Ubuntu – Enable NOPASSWD without manual interaction

sudo

I need to enable NOPASSWD for one user across 60+ hosts. I've only ever enabled it manually, using visudo. Is there a way to script this? I can easily log into all hosts as root, but I'm not sure if there is a command I can run to automatically add someone to the sudoers file with the NOPASSWD flag

Best Answer

Create a file with the required NOPASSWD line and drop it into /etc/sudoers.d. To verify the correctness of the file, use visudo to create it:

visudo -f some-file
cp some-file /etc/sudoers.d/

Then use scp or whatever means of control you use to send the files to the target systems.

sudoers.d files are read in lexicographic order, so use some numbering like 00-something, 99-most-important, etc. (like in /etc/grub.d/) to make ordering easier.

Related Question