DEV Community

Cover image for Fix Sudo not asking Password on Raspberry Pi
Akash Rajpurohit
Akash Rajpurohit

Posted on • Originally published at akashrajpurohit.com

Fix Sudo not asking Password on Raspberry Pi

Introduction

When you install a fresh copy of Debian or Raspbian on your Raspberry Pi you might notice that sudo does not ask for a password. This is a security risk and should be fixed. Let's see how to fix it.

Fix Sudo not asking Password on Raspberry Pi

This happens due to the NOPASSWD option for your user. We need to make sure that this option is not set.

We will edit the file named 010_pi-nopasswd. To find its location we will use the find command.

sudo find / -name 010_pi-nopasswd
Enter fullscreen mode Exit fullscreen mode

This will return the location of the file. In my case it is /etc/sudoers.d/010_pi-nopasswd. Now we will edit this file using visudo.

sudo visudo /etc/sudoers.d/010_pi-nopasswd
Enter fullscreen mode Exit fullscreen mode

The current content on the file will look like this.

<username> ALL=(ALL) NOPASSWD: ALL
Enter fullscreen mode Exit fullscreen mode

Where <username> is your username. We need to remove the NOPASSWD option. So the file will look like this.

<username> ALL=(ALL) ALL
Enter fullscreen mode Exit fullscreen mode

Save the file and exit. Now when you run sudo it will ask for a password.

Conclusion

We looked into how to fix sudo not asking password on Raspberry Pi. This is a security risk and should be fixed.

Follow my blog at akashrajpurohit.com

Top comments (0)