Change Default Sudo Password Timeout – How to Guide

sudo

When I run sudo and enter my password, a subsequent invocation of sudo within a few minutes will not need the password to be re-entered.

How can I change the default timeout to require the password again?

Best Answer

man sudoers says:

Once a user has been authenticated, [...] the user may then use sudo without a password for a short period of time (5 minutes unless overridden by the timestamp_timeout option).

To change the timeout, run, sudo visudo and add the line:

Defaults        timestamp_timeout=30

where 30 is the new timeout in minutes.

To always require a password, set to 0. To set an infinite timeout, set the value to be negative.

To totally disable the prompt for a password for user ravi:

Defaults:ravi      !authenticate
Related Question