Hacker News new | comments | show | ask | jobs | submit login

In case you want to access localhost on a server you're working remotely on, and would rather show localhost to your local machine than the world:

$ ssh -N <user>@<yourserver> -L <localport>/localhost/<serverport>

so if I'm bob at bobsbookwonderland.com, and I run a test server there on its localhost 5000 that I want to access from home, I'd type (from home):

$ ssh -N bob@bobsbookwonderland.com -L 5000/localhost/5000

and then on my local machine I'd just point my web browser to localhost:5000 as if I were running the test server locally.

The right way to do it is:

    $ ssh -N -L <localport>:localhost:<serverport> <user>@<yourserver>

    $ ssh -N -L 5000:localhost:5000 bob@bobsbookwonderland.com 

(the : is standard syntax used on platforms, including OSX and PuTTY, and some platforms don't support getopt arguments after the first non-flag argument)

Another useful setting is

    -g      Allows remote hosts to connect to local forwarded ports.
if you want to allow non-local connections.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact