This question already has an answer here:
What I would like to do is be able to login and sudo commands immediately without entering a password again. It is very redundant to type my password twice in a row when I need to login and run a privileged command. I understand the security risk which requires us to reenter a password when we've been away for awhile but it seems like login should automatically set this session by default to prevent this but it doesn't for some reason.
I am aware of these solutions but they both rely on gdm and I appear to only have LightDM installed for starters. Furthermore, I don't login to a GUI interface and AFAIK the console doesn't use either of these to manage logins in the first place.
I'm using Ubuntu 13.04 in VMware if that matters. I do have a KDE installed but I don't usually load it unless I have a reason to.
The ideal solution would also work from SSH logins.
Based on Gilles' suggestions I now have this working setup:
~ tail -n1 /etc/pam.d/sshd session optional pam_exec.so seteuid /usr/local/sbin/update_sudo_ticket
and (be sure to use
sudo visudo to edit sudoers)
~ sudo head -n12 /etc/sudoers|tail -n1 Defaults !tty_tickets
and create a new script
~ cat /usr/local/sbin/update_sudo_ticket #!/bin/sh touch -c "/var/lib/sudo/$PAM_USER" 2>/dev/null
and make it executable (
sudo chmod u=+rwx,g=+rx-w,o=-rwx /usr/local/sbin/update_sudo_ticket ):
~ ls -la /usr/local/sbin/update_sudo_ticket -rwxr-x--- 1 root root 57 Sep 21 20:52 /usr/local/sbin/update_sudo_ticket