I used to use this script to nightly terminate all user sessions and it seemed to work for quite a while, but it is no longer clearing out my sessions:
Xorg is no longer terminated, I have always started that after logging in via the console via startx. To remedy that recently, I added this:
I also noticed that my ssh-agent was not being killed, so I added this:
While that seems to have killed X and ssh-agent so I need to reenter my passphrase, it doesn't forcefully log me out of the console. I had thought about restarting the getty processes and tried sending a SIGHUP, but that seems to have messed it up rather than force me to logout.
What do others do to clear out user sessions nightly?
I'm the only user on this system, and my thought process from the start was that by limiting how long the sessions were, I would at least force the user to start a new session if somehow a malicious user obtained access and by doing so, it would at least potentially trigger more alerts than if they had maintained a session the entire time.
Code:
who | awk {'print$1'} | xargs -L 1 -I _USER_ pkill -KILL -u _USER_
who | awk {'print$2'} | xargs -L 1 -I _TTY_ pkill -KILL -t _TTY_
Xorg is no longer terminated, I have always started that after logging in via the console via startx. To remedy that recently, I added this:
killall Xorg
I also noticed that my ssh-agent was not being killed, so I added this:
killall ssh-agent
While that seems to have killed X and ssh-agent so I need to reenter my passphrase, it doesn't forcefully log me out of the console. I had thought about restarting the getty processes and tried sending a SIGHUP, but that seems to have messed it up rather than force me to logout.
What do others do to clear out user sessions nightly?
I'm the only user on this system, and my thought process from the start was that by limiting how long the sessions were, I would at least force the user to start a new session if somehow a malicious user obtained access and by doing so, it would at least potentially trigger more alerts than if they had maintained a session the entire time.