Raspberry Pi don't asking me for password when using sudo


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

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: ALL

And remove NOPASSWD: part:

pi ALL=(ALL) ALL

Save the changes and re-run a test command with sudo, it should require a password now.

2

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-nopasswd

and change

pi ALL=(ALL) NOPASSWD: ALL

to

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!!!

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like