Skip to content

Instantly share code, notes, and snippets.

@AviKKi
Last active December 29, 2020 15:48
Show Gist options
  • Save AviKKi/7b967ad822bdaaa693d47e3aa7bcc645 to your computer and use it in GitHub Desktop.
Save AviKKi/7b967ad822bdaaa693d47e3aa7bcc645 to your computer and use it in GitHub Desktop.
Practical aspects of using SSH tunneling are demostrated here, which can potentially replace services like ngrok, localtunnel, DDNS etc.
by default ssh daemon's config are stored in `/etc/ssh/sshd_config` and does not allow port forwarding, to enable it set `AllowTcpForwarding yes` and also `GatewayPorts yes`
using local and dynamic port forwarding.
TODO
include suitable description and examples.
`$ssh local_port:remote_addr:remote_port username@remote`
Assume an example where we I have a development server running on my local machine on port 8080, (i.e. http://localhost:8080/), and I have ssh access to a remote server(IP 3.182.212.9) that is exposed to the internet.
To tunnel it
1. run below command on your computer.
`$ssh -R 8080:localhost:8080 username@3.182.212.9`
2. in a browser open 3.182.212.9:8080
________________ ________________
| | | |
| Local server | <-----> | Public server | <-------> [ Internet ]
|________________| |________________|
This capability of ssh makes it pretty useful and competitive to services like ngrok,serveo, localtunnel etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment