sudo without password

sudo without password

ubuntu 20.04 server

It may be useful to run the sudo command without password, maybe you’re lazy, maybe your account has no password, or ssh password authentication are not permitted.

Passwordless login

⚠ Here may be dragons!

⚠ While playing with the sudoers system, a small error MAY lock you outside of your system. This can prevent remote AND local logins. Always keep a tty connected logged in as root. ⚠

  1. Create the file /etc/sudoers.d/50-sudonopass-group-passwordless
    # Users in the 'sudonopass' group don't need passwords
    %sudonopass ALL=(ALL) NOPASSWD:ALL
    
  2. Create the group sudonopass, if you know what a GID is, select a free one and, do that:
    sudo groupadd -g FREE_GID sudonopass
    

    or if you don’t:

    sudo groupadd sudonopass
    
  3. Add the user to the group sudonopass
    sudo usermod -a -G sudonopass the_user
    

~~~

Question, remark, bug? Don't hesitate to contact me or report a bug.