Add Your Username To Sudo Group And Run Sudo Without Password

First create the user

sudo adduser username

Then add it to the sudo group

usermod -aG sudo yourusername

Then edit the sudoers file. Run:


and add at the end of the file

yourusername ALL=(ALL) NOPASSWD:ALL

Another option is to allow passwordless sudo for any user in the sudo group.


# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL 


 # Allow members of group sudo to execute any command, no password

It might be better to make another file in the /etc/sudoers.d directory. If you have a typo or error of any sort, it will break sudo.

Don't forget to add your key to /home/user/.ssh otherwise you cannot login!

Then it might be a good idea to disallow root login