Passwordless Sudo

The default sudo requests a password for authentication
The default sudo requests a password for authentication.

At home, I have a Raspberry Pi that I use to develop my ROV and K-9 software. Raspbian seems to have passwordless sudo, meaning you don’t have to enter the user’s password to run a command as root. I share this development machine with my wife, Tamarisk.

In the interest of getting some more of the code written, at the expense of having a development machine available for some of the work while I am not at home, I have installed Ubuntu Server on a VirtualBox Virtual machine.

The default setup is that to run a command as ‘sudo’, you need to enter a password. To have passwordless authentication, I will need to make some configuration changes.

Use the following command to edit the /etc/sudoers file. Ubuntu opens the sudoers file in nano.

sudo visudo

My username is ‘pi’, so I added the following line to the bottom of the open file, then saved and exited (CTRL+X).

pi ALL=(ALL) NOPASSWD:ALL

Rebooting the machine applies the changes:

Now we have passwordless sudo on Ubuntu.
Now we have passwordless sudo on Ubuntu.

Why use visudo for editing sudoer file?

Usually, I would edit /etc/sudoers manually in a text editor like Nano; however, I have learned that this is not advised, as the risk of making errors that prevent me from logging into the machine is relatively high. The visudo tool creates a temporary file where you can edit the sudoers file using the default text editor. When you try to save your changes, it runs a syntax check and notifies you if there are any syntax errors.

Leave a comment

Your email address will not be published. Required fields are marked *

The maximum upload file size: 20 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop files here