The output below is from a host behind a firewall
user@rig04:~$ cat reverse_ssh.sh
#!/bin/bash
COMMAND="ssh -p8022 -N -f -R 0.0.0.0:18022:localhost:22 user1@host1
pgrep -f -x "$COMMAND" > /dev/null 2>&1 || $COMMAND
user1/host1 are in host accessible from the internet, public key authenticaion.
user@rig04:~$ crontab -l
# m h dom mon dow command
*/5 * * * * /home/user/reverse_ssh.sh
Also it is a good idea to configure keepalives, as NAT sessions tend to sleep on home routers.
user@rig04:~$ cat .ssh/config
ServerAliveInterval 10
ExitOnForwardFailure yes
At the end use ssh -p18022 user@localhost
from your host on the internet.
Cheers!