SSH Port Forward to reach a private intranet Service

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.

Scenario:

  • 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.

What do?

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

Example:

ssh -L localhost:9000:10.10.10.11:80 user@hostmachine.domain.com
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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s