How To Use SSH to Create a Remote Proxy

by Benson Wong

Most good sysadmins already know how to forward a local port to a remote machine and vice versa. However, sometimes it is useful to open a port on the remote machine to the world and have that traffic forwarded through SSH to your local machine.

A practical reason for this is if your web development server is sitting in the wild and you are in your comfy office behind a firewall. Perhaps you just want a wild server to forward a port into a box on your local network without anybody being the wiser. Well here’s how you do it.

  1. On the Remote Machine make sure this is in sshd_config, GatewayPorts yes
  2. Restart ssh
  3. On your local machine create the tunnel with:
    ssh -R 8080:localhost:8080 user@remotehost

Now you should be able to access remotehost:8080 and SSH will tunnel the traffic to your local machine.

PS: this could be a potential security problem if you’re not smart.

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: