Save sudo privilege for session

I have setup public key based login to my CentOS VPS. I wish to disable direct root login and have created an admin user under wheel group and have modified /etc/sudoers file and gave Wheel group all privileges.

But now I am being prompted for password whenever I type sudo. I do not wish to disable password prompting completely, but would like to save the status after first authentication.

Is this possible?

You can increase the timeouts, so it only asks you the password if you haven't used sudo in a while. Not sure you really want it saved forever, what if you have to walk away from the computer for a bit?

1 Like

Thanks. 30 mins should be more than enough for me.

One more question. In the thread that you linked to, it is mentioned that the sudoers file should be edited only with visudo. Yesterday I edited it with vi. Is it a problem?

It's a problem if you make a mistake. Use visudo because it runs sanity checks on sudoers as well as other things.

snippet from the man page

       visudo edits the sudoers file in a safe fashion, analogous to vipw(8).
       visudo locks the sudoers file against multiple simultaneous edits,
       provides basic sanity checks, and checks for parse errors.  If the
       sudoers file is currently being edited you will receive a message to
       try again later.
1 Like

Thanks for the clarification frank. Fortunately, I was the only person editing the file at that time. And all I did was remove the comment from the line granting wheel group all permissions.