How to set up an ssh connection from your wi-fi network

All the manuals suggest using port forwarding, like:

$ ssh user@remote_host -R 5555:localhost:22

but this doesn’t work if ssh tunnel shuts down. There is actually an autossh to solve this problem:

$ sudo autossh -M 0 -4 -N root@remote_host -R remote_port:localhost:22 -o “ServerAliveInterval 60” -o “ServerAliveCountMax 3” -o BatchMode=yes -o StrictHostKeyChecking=no -i /home/user/.ssh/id_rsa

-i allows you to use pub key to authenticate yourself on the remote host, so you won’t have to always use a password