In order to sync my home and work file systems I need to go via an intermediary computer and use port forwarding. Let us call the home computer A, the intermediate one B and the work computer C. From the command line I do this
ssh -N -f -L 2025:C:22 me_B@B && unison foo ssh://me_C@localhost:2025/foo
- I would like to put this one-liner into a bash script. How can I make it quit gracefully at the end and not leave any port forwarding still set up?