Actions before logout from ssh session
Is it possible to bind some actions which will be executed before logout from ssh
session?
I mean some config like .bashrc
, etc.
Solution 1:
If you enter the following into .bashrc
(or /etc/profile
, or .profile
, or any other start-up script) on the remote machine:
function onexit { xmessage "Exiting..."; }; trap onexit EXIT
You can replace the xmessage
command with anything you want: if you use /etc/profile
you will need to make checks that bash
is in a remote session, so as not to affect local sessions.
The answers here deal with exiting scripts, but are equally valid for the shell itself.