Once upon a time, a few years ago, there was on-site support for a hardware installation in a hotel. The remote tech’s desktop software wouldn’t play with my Linux laptop, so it couldn’t get into the switch it needed to configure for the installation to work. I asked if it had an SSH port that he could use, if he was in the room with me. Of course he did, but that didn’t do him much good. I performed a reverse SSH tunnel to my public server and pointed it to the switch on the local side. I convinced him to SSH to my server on the given port, and he was magically connected to his switch. He was literally impressed by that trick, and demanded to know how it could be done. SSH is magic, but tunneling traffic over SSH is pure magic. [Shawn Powers] agrees and decided to help the rest of us understand the process.
There are two basic ways to start a tunnel, the first is a local tunnel, which listens on the local machine and forwards it to the remote machine. On the other hand, a remote tunnel listens on the remote machine and delivers the traffic to the local machine. The real fun starts when you have multiple SSH sessions and connect one tunnel to another, running something exactly where you need it. For extra credit, check out the hidden SSH command line by pressing Enter, then tilde and the C key, one at a time. Also check out the rest of for extra credit [Shawn]’s Linux content, to learn some extra Linux goodness.
This post SSH is magic, but tunnels are even better was original published at “https://hackaday.com/2022/04/24/ssh-is-magic-but-tunnels-are-even-better/”