How to extend sudo password timeout
System administrators also authenticate as normal users and use sudo when administrative tasks are performed. The first time sudo run they asks for the password, after which sudo is active for a limited time.
The default password timeout is 15 minutes. Therefore, if sudo is run again within 15 minutes (900 seconds), the prompt to re-enter the password will not occur.
Extend sudoers timestamp timeout
The timestamp_timeout defines the number of minutes that elapse before sudo should ask for the password again. Edit the /etc/sudoers file to change the timestamp_timeout.
I recommend using command visudo to edit the /etc/sudoers file. Add the value timestamp_timeout on the line after “Defaults”, in the /etc/sudoers file.
$ sudo su
A grep shows the searched lines.
$ grep Defaults /etc/sudoers
here a sudoers at Linux Mint.
The default setting is “Defaults env_reset”.
$ sudo visudo
Extend sudo password timeout
Edit sudoers so that the Defaults line looks like this:
timestamp_timeout=-1 (minus one) causes the sudo password to never expire.
For Debian/Ubuntu distributions, the -0 option did not work. A higher value e.g. 60 is accepted.
timestamp_timeout=0 (zero) causes the sudo password to expire every 0 (zero) seconds. This means that each time sudo is called, the password is asked.
This post shows how to administrators also authenticate as normal users and use sudo when administrative tasks are performed. The first time sudo run they asks for the password, after which sudo is active for a limited time. This article shows how the time for the active session can be extended.