-   Linux - Networking (
-   -   Connect to a proxy through a middle host with a ssh tunnel (

iacchi 02-16-2012 07:55 AM

Connect to a proxy through a middle host with a ssh tunnel
Hi everyone,
I've tried to exploit this thing the whole morning, but I couldn't find a way out.
Let me explain my situation: my university gives to student a proxy access to the university network to let them look for science articles and so on on the net and download them without paying because the university already has contracts with them.
The problem is that the dorm I'm in has a firewall which doesn't let me connect to the proxy and the sysadmins already said that they won't open that port.

Fortunatly enough, I have ssh access on a server where I keep my personal website and so on, so I was thinking to use this opportunity (since I can do ssh from my dorm) to access the proxy. What I have in mind is this:

"my laptop" == ssh tunnel ==> "hosting server" == connect ==> "proxy server"

In this way I should be able to reach the proxy from within my dorm. Surfing the net I've found the program connect and this piece of information:
So, first of all I've tried to ssh into my hosting server and launched the connect command from there with


connect -p 3128 3128
and then create a ssh tunnel (from my shell) with


ssh -f user@hosting-server -L 3128:localhost:3128 -N
And it kind of works: setting firefox to use localhost:3128 as a proxy I can open one internet page, but after that the connect instance on the hosting server dies and I can't connect anymore. Basically, I shoud run again the program for each page I open.

Trying to keep things simple, I've also tried the command suggested on the link above, and from my shell I run:


ssh user@hosting-server connect 3128
but after asking for the ssh password I receive this message:


bash: connect: command not found
Of course connect is installed in the server and in the path.

So, do you have any suggestion on how I can make this thing work? It doesn't need to be a ssh tunnel or whatever, I just want access to the proxy.

acid_kewpie 02-16-2012 08:11 AM

I don't follow the logic of using the connect command. in your ssh command you're connecting to that socket that connect created, right? Well don't do that, just tell ssh to connect directly to the proxy, it's simpler than you think.

ssh user@hosting-server -L
that will give you a simple "dog legged" connection.

omgs 02-16-2012 10:17 AM

Just for the sake of being 100% sure everything will be understood:

1) The tunnel acid_kewpie mentions must remain open. If for any reason you close the connection, you just have to open it again.
2) You have to tell your web clients to use http://localhost:3128 as proxy

iacchi 02-16-2012 01:02 PM

It works like a charm, thank you very much. I'm still trying to grasp the full basics of ssh tunneling.

All times are GMT -5. The time now is 02:55 PM.