How to create a passwordless sudo user on Ubuntu Linux?

On Ubuntu Linux, if you want to create a user with sudo powers but without password, you need to follow a couple of steps:

1 - Create the user

Assuming you are logged in as root and want to create the user with deploy as username. adduser command, by default, will ask you to provide a password. To skip, use --disabled-password option.

adduser deploy --disabled-password
adduser deploy sudo

--disabled-password option will ensure you are not prompted to provide a password during the creation process. The second command, will make the deploy user a sudo user.

When you run any sudo command, you will still be asked for a password though. To avoid that, you also need to do the second step.

2 - Edit sudo file

As the root user, run the following command

sudo visudo

This will open a file (most probably in nano editor). Go to the end of the file and add the following line

deploy ALL=(ALL) NOPASSWD:ALL

If your user is called something else, replace deploy with that username. Save the file (for nano press Ctrl-X to save the file.)

And done

Now, whenever you will run any sudo command, you won’t be prompted for the password.

© 2023 Abhinav Saxena   •   Powered by Soopr   •   Theme  Moonwalk