ssh local tunneling – access home from remote location

Let’s say you have a raspberry running at home and you want to access it from your office.

If you have a google router you can easily set up IPv4 port forwarding 2222 -> 22

At this point from your work you can

ssh -p 2222 root@your-home-ip

and get inside your raspberry

In case you want to browse from your office your favourite web app running on port 80 (on your server at home), then you need to use a local port forwarding (lots of doc online about it)

-L local-port:host:remote-port

sudo ssh -p 2222 -L 80:localhost:80 root@your-home-ip

If you now open your browser and write localhost, you will hit the webapp at home that runs on port 80