Sudo immediately after login asks for password [closed]

If you think about it, it is kind of silly that sudo asks for your password even if you just logged into the machine and entered your password.

I realize that sudo and /bin/login are two entirely different mechanisms, but it would be nice if sudo didn’t ask for a password if your login session is less than, say, 30 seconds.

sudo doesn’t ask for a password more than once every 5 minutes by default. Similar to setting your screen-saver to kick in after 5 minutes of inactivity, this is a reasonable default for sudo.

Is there a way to fake out sudo so that it thinks the timeout hasn’t expired when I log in?


Here’s a good reason to not do it: You don’t always login with your password. You may be logging in with an SSH key. It may be a passwordless SSH key… and it may not be the right person who’s using it.

By requiring you to enter a password at least once, the system is protected against such occurrences.

If you still want to hack it (which I strongly advise against), you could have something write a new timestamp to the appropriate file in /var/db/sudo/tomontime/ when you login. If you write a program that does it, you could set that program to run with NOPASSWD in the sudoers file, and chain it to your .profile.

I really sincerely do not recommend it.

Source : Link , Question Author : TomOnTime , Answer Author : Jenny D

Leave a Comment