Skip to content

Instantly share code, notes, and snippets.

@Rajchowdhury420
Last active April 5, 2021 20:54
Show Gist options
  • Save Rajchowdhury420/2e9f94aba7fca83d9a74afeef2b0c4e0 to your computer and use it in GitHub Desktop.
Save Rajchowdhury420/2e9f94aba7fca83d9a74afeef2b0c4e0 to your computer and use it in GitHub Desktop.
SSH Tunneling (a.k.a. Port Forwarding)
SSH Tunneling (a.k.a. Port Forwarding)
===
This is how it works:
1. On the remote machine, the web server is running using whatever (maybe **non-public**) port we like (e.g. `9876`)
1. Use SSH to connect to the remote machine, but in a specific way that will forward a port on the remote machine to a port on our local computer (e.g. `8080`) -- this is the important part
1. On our local computer, we use our web browser to access the web server by providing the following URL address: `http://localhost:8080`
The important part
===
### **Linux** local computer ([more info](https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding)) ###
We connect to our remote machine using `ssh -L 8080:localhost:9876 george@example.com`
### **Windows** local computer ([more info](https://www.ocf.berkeley.edu/~xuanluo/sshproxywin.html)) ###
One simple solution is using an SSH client like [PuTTY](http://www.putty.org/) (or my prefered alternative/fork [KiTTY](http://kitty.9bis.net/)).
1. Go to "Connection" -> "SSH" -> "Tunnels"
1. Tick the option "Remote ports do the same (SSH-2 only)"
1. In the "Source port" field use `8080`
1. In the "Destination" field use `example.com:9876`
1. Click "Add"
1. Connect to the remote machine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment