Some task which I always do when owning a private Linux machine (Debian, bash).
Keeping SSH session open:
With the setting below, my SSH client will send a keepalive to the SSH server every 30 seconds to keep the session up, and prevent session time-out
mmoghaddas@debian:~$ egrep 'Host|Alive' /etc/ssh/ssh_config Host * ServerAliveInterval 30
Obviously you can also set similar settings on SSH server:
moghaddas@debian:~$ egrep Alive /etc/ssh/sshd_config ClientAliveInterval 60 ClientAliveCountMax 0 TCPKeepAlive yes
Run scripts immediately on login:
Just create a script and put inside /etc/profile.d/SCRIPT.sh
Run scripts immediately on logout:
Easily by adding everything in .bash_logout
For example creating different scripts, and referencing them inside this file.
Run scripts on session timeout:
Well, this is actually not 100% on timeout, but when a session times out and then someone logs in. You can create a script, then tail the auth.log (if available) and awk
for Timeout, then run the script:
moghaddas@debian:~$ cat /etc/profile.d/ bash_completion.sh SCRIPT.sh moghaddas@debian:~$ cat /etc/profile.d/SCRIPT.sh tail /var/log/auth.log | awk '/Timeout, client not responding/ { system("sh TIMEOUT.sh") }'