0

From internet, I have access via ssh to the Machine_A and it can access the intranet. So, I can access all intranet sites with command line like:

ssh Machine_A -f 'curl -s http://192.168.0.51' > index.html

The problem is that a web site is a complex thing. It need to download images, javascript, css, etc.

Soo, how can I "tunnel" or "translate" my connection to access the website only using command lines?

See this scenario:

  • I want to acess the page in http://192.168.0.51
  • So, I connect with ssh and download the page with the above command.
  • I open the index.html and the browser see it need to download image.jpg and script.js
  • Somehow, I intercept this request, make the correct line to download the file and than the browser use it

How can I access this site without direct access? What could I do in Machine_A to be my "gateway" to access the intranet site?

1 Answer 1

3

What you want to do is set up an SSH tunnel and set a browser to proxy the traffic over that tunnel, then you will have access to those resources in that browser.

Since you don't want to setup your whole computer or main browser to use this SSH tunnel, you can use an alternate browser, but it needs to be such a browser that lets you independently configure a proxy. Firefox allows you to do it, and if you use Firefox as a regular browser, you can use a Firefox fork like Waterfox or Pale Moon which also lets you set up a proxy independently from the system or from Firefox.

To start the tunnel, connect to the SSH host with the following parameters:

ssh -ND 9999 Machine_A

This will connect to Machine_A and create a tunnel on port 9999 (or any port you set it to).

Leave the ssh connection running, and in Firefox (or similar browser) set the proxy:

  1. Open Settings
  2. Scroll down to the Network Settings section and click on the Settings... button.
  3. In the new window that opens:
    • Select the Manual proxy configuration radio button
    • Enter 127.0.0.1 in the SOCKS Host field and 9999 in the Port field
    • Check the Proxy DNS when using SOCKS v5 checkbox
    • Click on the OK button to save the settings.

Now you should be able to browse the intranet site, in this browser, like you are local.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .