2

I have a very different situation. My laptop named A, another machine B(ip-172.16.28.3) with ssh server installed and i have an account on that machine, the third machine C(ip-172.16.24.3) is a proxy server. All the machines are within a LAN, but

1- Machine B can connect to A as well as C

2- Machine A i.e.my pc, it can only connect to B and not C

Now to use internet, i do the following:

ssh -X [email protected]

Then i type firefox and i use the firefox of machine B with proxy setings as 172.16.24.3:3128

Instead of using firefox of B, i want to use my local firefox. Is there a way through which i can connect to C via B and use my local firefox for browsing

2 Answers 2

0

Since laptop A has ssh access to B, and B has access to port 3128 on machine C, you can set up port forwarding to bind port 3128 on machine C to port 3128 on your local computer (A). Then you can set up firefox proxy settings on your laptop to localhost:3128 and it will be using port 3128 on machine C for proxy services.

ssh -L 3128:172.16.24.3:3128 [email protected]

Explanation:

-L = Take a remote port and bind it to some local port
3128 = The local port to bind to
172.16.24.3 = The remote host (proxy server) who's port you want access to.
3128 = The port on the remote host (proxy server) that you want access to.
[email protected] = the ssh server 

This method can be used to gain access to any port on any machine that the ssh server can see on the network (one port at a time).

Once a connection is established, you can set up firefox on your laptop just as it is on machine B except use localhost:3128 instead of 172.16.24.3:3128 in the proxy settings.

("localhost" should be the same thing as 127.0.0.1)

14
  • Thanks for such a detailed answer, but it is not working because i don't have an ssh account on 172.16.24.3. I can't even connect to 172.16.24.3 directly. You have used [email protected] instead of [email protected], as a result the above request simply times out! Commented Mar 26, 2012 at 0:04
  • @adnan kamili Sorry I mixed up the addresses. I think I fixed it.
    – James T
    Commented Mar 26, 2012 at 0:07
  • 172.16.28.3 is the ssh server and 172.16..24.3 is the proxy server, you made a mistake! but ssh -L 3128:172.16.24.3:3128 [email protected] also does not work. Commented Mar 26, 2012 at 0:11
  • @adnan kamili At what point does it fail to work? Are you able to connect to the ssh server? Does it fail when you try to use firefox? Do you get any error messages?
    – James T
    Commented Mar 26, 2012 at 0:14
  • 1
    It worked atlast, i was using 127.0.0.1:3128 as socks proxy in firefox, i should have used it as http proxy, since there is a http-squid proxy installed on 172.16.24.3. Thank you very much! Commented Mar 27, 2012 at 16:28
0

The -D argument allows ssh to create a SOCKS proxy which you can then connect to with Firefox.

Example:

ssh -D 127.0.0.1:9051 [email protected]

Then you open Firefox and set 127.0.0.1 with port 9051 as a SOCKS5 proxy.

For more information, see man ssh.

3
  • It doesn't work, if i use ssh -D 9999 [email protected] and use 127.0.0.1:9999 as proxy in local firefox, nothing happens because 172.16.28.3 is not a proxy server Commented Mar 25, 2012 at 21:29
  • I also tried proxychains, to chain the local proxy server created using ssh -D with 172.16.24.3 and results are somewhat weird. |DNS-request| www.google.com |S-chain|-<>-127.0.0.1:9999-<>-172.16.24.3:3128-<><>-4.2.2.2:53-<--denied Commented Mar 25, 2012 at 21:32
  • ssh -D 127.0.0.1:9051 [email protected] , still the same Commented Mar 25, 2012 at 22:44

You must log in to answer this question.

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