Eliminate the time period during which sudogksu powers hang around

By default sudo/gksu will "remember" your password for a short while after you use them, so that if you use sudo/gksu again, you won't be prompted. This can make using sudo/gksu less annoying but can also create security concerns—if you temporarily leave your computer unattended, for example, anybody who uses it will have sudo powers for that short period.

If you type sudo -K after each use of sudo, the password will be required again the next time sudo/gksu is used. To do away with the grace period forever, you need to edit the /etc/sudoers file, and to do that issue the following command at the terminal: sudo visudo. This opens the vim text editor which is rather less than intuitive, but it's not hard to use. Use the cursor keys to move down to the end of the line that reads Defaults env_reset, and hit Q. Then type timestamp_timeout=0, so that the complete line now reads:

Defaults env_reset,timestamp_timeout=0

Then hit [Esc], type :wq, and hit [Enter]. This will save the file and quit vim.

The change will take effect immediately. If, for any reason, you want to make sudo/gksu NEVER forget your password, so that you won't be prompted after you initially use sudo/gksu (until you log out of that particular command-line session), change the line to read: Defaults env_reset,timestamp_timeout=-1

This is obviously very insecure, however. Note that if you make a mistake while editing the /etc/sudoers file, hit [Esc], type :q!, and hit [Enter]. This will quit the text editor without making any changes. Then try again.

For more sudo and password-related tweaks, see Tip 271, on page 311; Tip 200, on page 237; and Tip 78, on page 137.

Was this article helpful?

0 0

Post a comment