Skip to content

Instantly share code, notes, and snippets.

@dafang
Created December 24, 2012 16:06
Show Gist options
  • Save dafang/4369774 to your computer and use it in GitHub Desktop.
Save dafang/4369774 to your computer and use it in GitHub Desktop.
How to expose local ports via server
  • Change server sshd_config to allow client binding artitray network interface

    GatewayPorts yes
    
  • Use -R [bind_address:]port:host:hostport to setup port forwarding. bind_address should be 0.0.0.0, which means binding on all network addresses. Following example forward local ports 3000 to server 8080, and local ports 22 to server 2222. So others can open http://server:8080 to access your web server, and ssh -p 2222 server to log into your local machine.

    ssh -R 0.0.0.0:8080:localhost:3000 -R 0.0.0.0:2222:localhost:22 server
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment