I use sudo to provide permissions and command execution rights to other users under UNIX and Linux operating systems. However, I noticed something strange about sudo. When executing sudo, it will prompt for the user's password the first time, but sudo no longer requires a password anymore when re-executing it. Why? Is this is a security risk?
The sudo tool records the timestamp by creating a file, when it is executed the first time, sudo won't need a password if the timestamp has not timed out. The default time out value is 900 seconds (15 minutes).
timestamp_timeout Option
The timestamp_timeout defines the number of minutes that can elapse before sudo will ask for a password again. The default is 5. Set this to 0 to always prompt for a password. If set to a value less than 0 the user’s timestamp will never expire. Edit /etc/sudoers, enter:
# vi /etc/sudoers
You can also use the visudo command, which edits the sudoers file in a safe fashion:
# visudo
Set timestamp_timeout as per your requirmehnt or 0 so that it will always prompt for a password:
timestamp_timeout 0
Save and close the file.
sudo -k command line option
The -k option allow users to create or delete their own timestamps via sudo -v and sudo -k respectively. Run sudo -k to invalidate the timestamp after executing sudo command:
$ sudo -k
passwd_timeout Option
The passwd_timeout defines number of minutes before the sudo password prompt times out. The default is 5, set this to 0 for no password timeout. Edit /etc/sudoers, enter:
passwd_timeout 2
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 5 comments… read them below or add one }
I really didn’t understand anything. HOW DO YOU CHANGE the timestamp_timeout ?
Add that in sudoeds ? Nothing happened i got a parse error.
Sudo -k does nothing
HOW ?
“The time out value is 600 seconds (5 minutes) by default. ” – 600sec != 5min…
I think there are some errors in this article:
1. “vi timestamp_timeout” should be “visudo” or “sudo visudo”.
2. There are no “Defaults” before timeout settings.
Thanks for the heads up. According to man page:
The faq has been updated.
There is a setting in the /etc/sudoer’s file that an entry you can add to force it to skip prompting for passwords (example below):
girish ALL=(ALL) NOPASSWD: ALL
The NOPASSWD tage will force sudo to skip the password prompt you can remove that tag and it will force you to enter the password
girish ALL=(ALL) ALL
Thanks
Girish