You may want to give password-less sudo access to specific users of group sudo. This is already done in many AMIs on AWS for example.
Edit sudoers files
You'll need to edit the sudoers file, which in ubuntu is at
/etc/sudoers. To edit it you should use:
You'll need to add an entry after the following
The entry to add should be of the form
<username> ALL=(ALL) NOPASSWD: ALL
See below for an example of a
sudoers file with
example-user given password-less sudo access.
# This file MUST be edited with the 'visudo' command as root.
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
# See the man page for details on how to write a sudoers file.
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
# Give myself passwordless sudo
example-user ALL=(ALL) NOPASSWD: ALL