No sudo password prompt after login?

cjxzjcxzjz

New Member
Joined
Mar 24, 2020
Messages
11
Reaction score
2
Credits
102
Hi,

When I succesfully login on Ubuntu server through the terminal and execute a sudo command, it prompts me again for a password while I just logged in. I don't want to be prompted for a password when executing a sudo command after I just logged in. I do want the system to prompt me again for a password when executing a sudo after 30mins.

I tried:
- Setting nopasswd and Defaults env_reset,timestamp_timeout=30 in the sudoers file but this doesn't accomplish what I want. Because of the nopasswd , I never get prompted for a sudo password.
- When I remove nopasswd, the timeout mechanism works but I again get prompted for a password when executing a sudo command after I succesfully logged in which is what I don't want.

On my Raspberry Pi, which also has a Debian based image, it works the way I want out of the box but I can't seem to find the setting for it.

Does anyone know how to accomplish this? Thanks in advance.
 


Raspberrypi os uses :
/etc/sudoers.d/010_pi-nopasswd

Which has:
pi ALL=(ALL) NOPASSWD: ALL
 
Have a look here
Thanks but that doesn't really solve my issue. Maybe the scenario I'm trying to achieve isn't possible.

Raspberrypi os uses :
/etc/sudoers.d/010_pi-nopasswd

Which has:
pi ALL=(ALL) NOPASSWD: ALL
Thank you, didn't know that. It seems the Pi also doesn't seem to ask for a password after X minutes.
 
I think the problem is that you added nopasswd to the file
Code:
sudo visudo
It will open a file in your text editor that contains some settings related to sudo. In here look for the following line:
Code:
Defaults   env_reset
Replace above line with this one:
Code:
Defaults   env_reset, timestamp_timeout=30
Where 30 is the new timeout value in minutes.
Once you are done changing the default sudo password timeout, use Ctrl+X to exit the editor. It will give you option to save or cancel the changes. Use Y to save the changes.
 
I think the problem is that you added nopasswd to the file
Code:
sudo visudo
It will open a file in your text editor that contains some settings related to sudo. In here look for the following line:
Code:
Defaults   env_reset
Replace above line with this one:
Code:
Defaults   env_reset, timestamp_timeout=30
Where 30 is the new timeout value in minutes.
Once you are done changing the default sudo password timeout, use Ctrl+X to exit the editor. It will give you option to save or cancel the changes. Use Y to save the changes.
Hi, that's what I already did. See startpost. The problem with this solution is that the timeout mechanism works, but it still prompts me for my password AFTER i just logged in which is what I don't want.
 
On your Raspberry Pi where it does work like you want check out what the contents of /etc/pam.d/sudo look like, if that has include check out what that include(s) look like. I suspect that configuration you are wanting, to only be asked for a sudo password after 30 minutes, is hidden somewhere in the pam configuration. Once you find out how it is configured on your Raspberry Pi you can setup that same configuration on your Ubuntu Server.
 

Members online


Latest posts

Top