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
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
The current content on the file will look like this.
<username> ALL=(ALL) NOPASSWD: ALL
Where <username>
is your username. We need to remove the NOPASSWD
option. So the file will look like this.
<username> ALL=(ALL) ALL
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)