Skip to content

Instantly share code, notes, and snippets.

@doitian
Created December 20, 2012 08:21
Show Gist options
  • Save doitian/4343765 to your computer and use it in GitHub Desktop.
Save doitian/4343765 to your computer and use it in GitHub Desktop.
Expose local ports via server through ssh port forward
  • 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
    
@magzim21
Copy link

Does it make sense without preconfiguring DNS ?

@doitian
Copy link
Author

doitian commented Mar 29, 2020

It depends. IP is enough to host a temporary demo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment