Since alot of time, my Raspbian install is no longer asking me my password while using sudo, and that's a security issue because it can be accessed remotly.
I searched on Google how to enable that, but the only things I seen is how to disable that.
After logging in using ssh:
pi@WS-RPI-10666:~ $ sudo echo a
a
pi@WS-RPI-10666:~ $
Regards,
Minteck
2 Answers
If sudo is not asking for password that means you probably haveNOPASSWD in /etc/sudoers. As described in man 5 sudoers:
NOPASSWD and PASSWD
By default, sudo requires that a user authenticate him or herself before running a command. This behavior can be modified via the NOPASSWD tag. Like a Runas_Spec, the NOPASSWD tag sets a default for the commands that follow it in the Cmnd_Spec_List. Conversely, the PASSWD tag can be used to reverse things.
Never edit /etc/sudoers directly, run sudo visudo instead. Locate
a line that sets permissions for a specific user you're interested,
say pi:
pi ALL=(ALL) NOPASSWD: ALLAnd remove NOPASSWD: part:
pi ALL=(ALL) ALLSave the changes and re-run a test command with sudo, it should require
a password now.
For Debian bullseye edition
we cannot find 'NOPASSWD:' in /etc/sudoers
it should be in /etc/sudoers.d/010_pi-nopasswd
so you can edit it by
sudo visudo /etc/sudoers.d/010_pi-nopasswdand change
pi ALL=(ALL) NOPASSWD: ALLto
pi ALL=(ALL) ALL(remove 'NOPASSWD:')
and save and close...
if you make any mistake, it will promt that... press e to go back to editing NEVER PRESS q!!!