during a recent nagios setup on a private lan with no web access to it from the outside, i came accross a cool little trick to forward a port to a non-used port on your machine.

ssh -L(virt_port):(ip_addy):(port) (user)@(server)

let me explain, i need to connect to the nagios server which we’ll say is located at x.x.x.x:8080 inside of my lan (with no web access from the outside) and the ssh server on this lan is addy y.y.y.y . on my laptop we will assume that port 9000 is not being used for anything (this will be our mapped port on local machine). the syntax would be:

ssh -L9000:x.x.x.x:8080 user@y.y.y.y

once ssh’d into the ssh server, just open up a browser and in the addy section put in the addy of the web server with virtual port

localhost:9000

you should see whatever it is that you are trying to connect to in the browser now.

keep in mind, it does not have to be port 9000 as the virtual port, it can be anything that is not being used on the local machine.