This is a very short reminder for myself how to set up a reverse SSH tunnel between two computers, using an intermediate Raspberry Pi computer that can be accessed from both.
This assumes that you have three computers
- A remote linux computer that you want to tunnel to. You should be able execute commands on it, for example through VPN, TeamViewer or so.
- A raspberry pi or similar linux computer at home that is in the DMZ of your home network, i.e., it can be directly accessed from the internet.
- Your macbook that you want to connect to.
The schematic connection setup is like this:
remote -> raspberry -> macbook
macbook -------------> remote
On the remote Linux computer that you want to access over ssh:
ssh raspberrypi.local -R 2022:localhost:22
On the raspberry pi, where you are now logged in:
ssh macbook.local -R 2022:localhost:2022
On your macbook on which you are actually working:
ssh localhost -p 2022
This will connect you directly from your local macbook to the remote linux computer.
To use rsync over ssh, you have to explicitly specify the port
rsync --progress -arpv --delete -e "ssh -p 2022" <localpath> <remotepath>