I'm logging in to a system via SSH and I'd like to be able to force a command to be run on logout, whether that's an intentional logout (exiting the shell) or because my SSH connection has dropped/been terminated. Is there any way to set this up? My best guess right now is to change the login shell to a program that intercepts the signal sent on SSH closing (SIGHUP?) and executes the command then, but I'm wondering if there's a cleaner solution.
The best way to do this would be to use pam.
Once you've identified the file in
This will result in calling
Now you just need to create
(don't forget to
I would try to do it with