SSH Over Socks Proxy – How to Connect Without Username or Password

backtrackPROXYsockssshssh-tunneling

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.

Best Answer

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.

Related Question