SSH port forwarding in nutshell

My goal: I want to see the intranet website from home with my linux laptop. I can connect over SSH to the intranet web server. But I want to see the webpage in a browser of my laptop.

The solution is SSH port forwarding. From my Linux laptop. Here is the syntax:

ssh -L <myPortNumber>:<RemoteIP>:<RemotePort>  <host> [other ssh options like port and user]

I used this:

ssh -L 8088:127.0.0.1:80  intranetserver.example.com

Now I can click to http://localhost:8088/ on my favorite browser and I can browse the intranet.

The first port number is your machine port number recommended to be higher than 1024. If you give a port less than 1024 you have to be root. Check the selected port with netstat. Netstat lists any used port:

netstat -ltn --prog

Do not give any portnumber that is in this list. These ports are used by another applications.

Jozsef

Read more posts by this author.