When running scripts as sudo, it is convenient not to be prompted for a user's password. Password prompts defeat automation so this post will demonstrate how to disable the password prompt associated with the sudo command.
The command sudo date is often used to determine if invoking sudo will prompt the user to enter their password (as follows):
Above, it can clearly be seen how the sudo before the date command causes a password prompt for the password of user devops.
The sudo command allows commands to be elevated and run as root. In order to use the sudo command, a user must be part of the sudo group. The following post demonstrates how to add a user to the sudo group: Ubuntu: Adding a user to the sudo group.
To disable the sudo caused password prompt invoke the command
sudo visudo
Running the above command does require a user to enter their password in response to sudo (hopefully for the last time):
The visudo command is an editor for the /etc/sudoers file. visudo validates the sudoers file's format on save. The man page for the sodoers file can be found at Sudoers Manual.
visudo brings the sudoers file up in an editor:
<user name here> ALL=(ALL) NOPASSWD: ALL
devops ALL=(ALL) NOPASSWD: ALL
Use ctrl-s to save the file and cttrl-x to exit the editor.
Once the sudoer file has been edited correctly and saved, a user should no longer be prompted to enter a password when invoking the sudo command.
No comments :
Post a Comment