I’m familiar with using SSH Port Forwards for the purpose of forwarding a port on remoteMachineX to my localMachine, and vise versa, yet somehow before now I have not realized how to read the port of remoteMachineY through my SSH access to remoteMachineX. I’ve been wondering how to do this for a long time but never got the question right to figure it out.
- Have: remoteMachineX and remoteMachineY on the same private network.
- Have: SSH access to remoteMachineX.
- Do not have: SSH access to remoteMachineY, it’s only serving (for example) the HTTP protocol on port 80 on it’s private interface.
- Want: to browse remoteMachineY’s website.
Reading this article it suddenly became clear to me how to do this easily with SSH port forwards.
Before now I’ve only ever port forwarded to/from localhost ports, like this:
ssh -L localhost:9000:localhost:80 user@remoteMachineX.com
Which is more commonly abbreviated:
ssh -L 9000:localhost:80 user@remoteMachineX.com
and accomplishes the ability to read port 80 of remoteMachineX on your localMachine’s port 9000; but if you want to access port 80 of remoteMachineY through the local private network of remoteMachineX, you can:
ssh -L localhost:9000:remoteMachineY:80 user@remoteMachineX.com
ssh -L localhost:9000:10.10.10.11:80 firstname.lastname@example.org
then hit localhost:9000 in your localMachine’s browser.
Note: I often use port 9000 on my localMachine, since localhost ports below 1024 (typically) are restricted and would require sudo privileges. 9000 is also easy to type on the keyboard and remember in the brain.