Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 user@172.16.28.3

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

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

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 user@172.16.28.3

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.
user@172.16.28.3 = 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)

share|improve this answer
    
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 user@172.16.24.3 instead of user@172.16.28.3, as a result the above request simply times out! –  adnan kamili Mar 26 '12 at 0:04
    
@adnan kamili Sorry I mixed up the addresses. I think I fixed it. –  James T Mar 26 '12 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 user@172.16.28.3 also does not work. –  adnan kamili Mar 26 '12 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 Mar 26 '12 at 0:14
    
Yes it connects to ssh server. When i put proxy 127.0.0.1:3128 in firefox the request simply times out. –  adnan kamili Mar 26 '12 at 0:21
show 9 more comments

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 user@172.16.28.3

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

For more information, see man ssh.

share|improve this answer
    
It doesn't work, if i use ssh -D 9999 user@172.16.28.3 and use 127.0.0.1:9999 as proxy in local firefox, nothing happens because 172.16.28.3 is not a proxy server –  adnan kamili Mar 25 '12 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 –  adnan kamili Mar 25 '12 at 21:32
    
ssh -D 127.0.0.1:9051 user@172.16.28.3 , still the same –  adnan kamili Mar 25 '12 at 22:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.