Sometimes I ssh into a box, and run some script that makes a change to the system. I want to undo this change when my session ends, either explicitly (e.g., via
exit from the logout shell) or implicitly (e.g., because my ssh session times out).
Can I set up something that will accomplish this?
As a strawman example, assume I create a file
/etc/foo and at the same time I want to register a cleanup script which does a
rm /etc/foo at some point when my ssh session ends.