Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a list of SOCKS proxy servers from this site.

I've read about creating a dynamic tunnels with ssh -D and to be honest i've tried that already. Unfortunately for some reason I cannot connect to any of the proxy servers from the list.

I am using OpenSSH_5.3p1 Debian-3ubuntu7, OpenSSL 0.9.8k on BackTrack. If anyone would be willing to help or point to step by step guide which will work for me I would be very grateful.

What I want to achieve is Connect from Machine A through ssh tunnel on Machine B to Machine C. Lets say sshd on Machine C is listening on port 21 and Machine B proxy is listening on port 1080.

Additional Question:

I would also like to create a tunnel to socks proxy server which would allow me to setup localhost:8080 in firefox as a proxy and allow me to browse the net from the Machine B with Machine B IP address.

share|improve this question
What are you trying to do? Am I right to assume that "Machine B" is supposed to be from that list? – sr_ Oct 2 '12 at 10:39
I'm trying to use a server in the middle as a jump proxy to connect to third machine. the B machine is from the list - correct. I would also like to create a tunnel to socks proxy server which would allow me to setup localhost:8080 in firefox as a proxy and allow me to browse the net from the Machine B with Machine B IP address. – mnmnc Oct 2 '12 at 10:44
Why are you running ssh on port 21? – Flimzy May 14 '13 at 9:19
up vote 10 down vote accepted

It sounds to me like you need a socks client, or a ssh client that understand socks. -D is for ssh to be a socks server/proxy.

You could use ssh under tsocks, or another SOCKS wrapper. Or use ssh's ProxyCommand in conjunction with socat or nc -X:

ssh -o ProxyCommand='socat - socks:B:%h:21,socksport=1080' C

To have a HTTP proxy that uses the SOCKS server to send HTTP requests, you can run a small proxy (like tinyproxy) under tsocks.

Note that not all applications play nicely with tsocks or any similar wrapper that relies on LD_PRELOAD, but tinyproxy does.

Also note that you may have issues with domain name resolution (depending on whether you want the names to be resolved on either side of the tunnel). tsocks doesn't work well for resolving names remotely. The only way it can work is when your nameserver (in /etc/resolv.conf) is reachable from the other end and you're using TCP for domain resolution (which tsocks can attempt to enforce but generally fails in my experience). socksify from dante's SOCKS client/server works better in that instance as it also wraps resolving functions and can also use a nice little trick to fake name resolution so that SOCKS by-name connections can be used.

share|improve this answer
YEY ! It works ssh -o ProxyCommand='socat - socks:,socksport=1080' C. Thats really great. Thank you. Would you be able to suggest a command to create a tunnel with this socks proxy that i could setup in firefox as a local web proxy? Im not sure if this can work : Firefox + local port tunnel -> socks tunnel Machine B -> HTTP Server. If it is possible and you know how to do this, please share and i promise you +100 :) for that. If it is impossible i will still give +50 for the answer above. – mnmnc Oct 2 '12 at 10:40
Firefox supports socks directly (see proxy options in advanced, network settings) – Stéphane Chazelas Oct 2 '12 at 10:44
Ok. Maybe i misguided you by suggesting Firefox. Lets say CURL - and i want to connect via local proxy so i can automate in bash script the tunnel creation. – mnmnc Oct 2 '12 at 10:45
Well, curl supports SOCKS as well. So you'd like to turn a socks proxy into an HTTP proxy? Then you can run an HTTP proxy server (like tinyproxy) under tsocks – Stéphane Chazelas Oct 2 '12 at 10:50
Ok. tsocks seems to be exactly what i need. prize in 2 days as promissed. Thank you very much. :) – mnmnc Oct 2 '12 at 10:56

Your Answer


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.