Reverse SSH tunnel from Hunter to Base

— door Evert Mouw

This is my method to keep connected with a remote Raspberry Pi that has a static external IP address and lives behind a NAT, where I don’t have control over the router (so no port forwarding). For your use case, you might want to choose another method (there are plenty on the world wide web, I’m sure you can find them), but the simple method below works for me.

on Base

Create a new user with adduser tunnel

You need a modification to sshd_config. At the end of the file, add a Match block to prevent password-based logins (only allow keybased logins for user tunnel) so the password above is of little use to the outside world

on Hunter

Login to Hunter. I assume evert as your username on Hunter

Create the reverse tunnel using:

Or, more sophisticated:

This can be done best by doing it from cron and with a script.

My script has a few more tricks (updated 2017-12) and is named tunnel.sh.

You can download my files: reverse_ssh_tunnel.zip

Usage

First login to Base, then connect to Hunter using:

And from there, you can play with Hunter.

Have fun!

Hunter base shot from Mega Man X5
Just a random picture from the internet. “Hunter base shot from Mega Man X5”, source: Megaman wikia
     

Facebook Comments