# socks4/5 proxy using ssh -D



## Brin

Hello,

I read that if I run the command in ssh then I can have a socks4/5 proxy on my 1080, for me to use:

ssh -D 1080 [email protected]

Im on windows xp and I cant run this on putty or on ssh?
I login to a shell account online and when I try to use host as the server that I logged into it doesnt accept connection.

Do I run that command in cmd? I'm having problems with cmd and trying to fix it so...

cmd or something else?

Thanks


----------



## Brin

Is it even possible?


----------



## jiml8

I don't understand what you are trying to do. If you do an ssh -D 1080 [email protected] then ssh will function as a socks proxy. You then have to set up your application to point its socks interface at localhost:1080.

Also, of course, site.com has to be running an ssh server.


----------



## Brin

Ya, thats what I was saying.

My question one...Where do I type the "ssh -D 1080 [email protected]" ?

I have a socks account on 217.133.6.198

When I login and type "ssh -D 8128 [email protected]" after the $ cursor thing, it says:
ssh: connect to host 217.133.6.198 port 22: Connection refused

Its a free shell account so maybe thats why. Or I'm typing it in the wrong spot, because I don't know anywhere else to type except after I login? If it'll work on a paid shell account, I can get one from fluidhosts.com...

Thanks! Hoping that this will work because I really want one 

EDIT: I have managed to do this... 
1.) connect to a shell
2.) connect to another shell using that command on port 8128
3.)put in password so that I'm not logged in the second shell where the first shell is like a "proxy"

But, I cant use localhost:8128 as a server nor first.shell:8128 as one either.

I think I have to run that command on my computer so only one connection to one shell is present?

But, I dont think windows has a command line interface...? Not sure if it'd work on cmd...I think it would if I put in a live cd for a linux OS or something...


----------



## jiml8

Brin said:


> When I login and type "ssh -D 8128 [email protected]" after the $ cursor thing, it says:
> ssh: connect to host 217.133.6.198 port 22: Connection refused


This means that 217.133.6.198 does not have an ssh daemon watching port 22. If that host has sshd running, you will have to find out what port it is using and use the -P option on your ssh -D command. Alternatively, you will have to relay through another computer to the socks port on 217.133.6.198.

Yes, you do type the command ssh -D on the computer you are using as a client.



> EDIT: I have managed to do this...
> 1.) connect to a shell
> 2.) connect to another shell using that command on port 8128
> 3.)put in password so that I'm not logged in the second shell where the first shell is like a "proxy"
> 
> But, I cant use localhost:8128 as a server nor first.shell:8128 as one either.


None of this is clear. How, exactly, did you "connect to a shell"? From what computer to what computer using what command? How did you "connect to another shell..." using WHAT command? Again, from what computer to what computer using exactly what command line?

I don't understand your number 3 at all.



> I think I have to run that command on my computer so only one connection to one shell is present?
> 
> But, I dont think windows has a command line interface...? Not sure if it'd work on cmd...I think it would if I put in a live cd for a linux OS or something...


cmd doesn't support this stuff.

I use cygwin on Windows because I like the unix environment and with cygwin I get that, and I can use the bash shell. The commands you are entering here are strictly correct if you are using cygwin.

www.cygwin.com

If you want the windows-like interface, take a look at PuTTY. It will do what you want.

http://www.chiark.greenend.org.uk/~sgtatham/putty/

Again, this will only work if your destination box is running an ssh daemon (server). If it isn't you'll have to port forward through some other box that is running sshd.


----------



## Brin

Thanks for the long post!

I think cygwin was what I was looking for. I have no idea how to ssh directly from my comp to my shell account using putty...

I had a live linux CD and I tested it on my laptop--I was able to SSH to my shell account. Directly from my computer to ssh. WHen I try the same thing on cygwin I cant do it because it doesnt have the ssh command. How do I install openssh so that it works with cygwin?

I searched for it in the package list search and found it but it wasnt anything to download...

Im looking through the setup tree but can't find ssh support. 

So, how this works, I think...

I ssh to my shell account directly from my computer using cygwin using the following:

ssh -D 1080 [email protected]

then the socks5 server would be localhost:1080

Right?

Well, if it is correct, it should start working when we have ssh setup on cygwin 

Thanks!


----------



## Squashman

Brin said:


> Thanks for the long post!
> 
> I think cygwin was what I was looking for. I have no idea how to ssh directly from my comp to my shell account using putty...


If it is a Windows box, just use putty.

Quote from Cygwin.


> Note that, when installing packages for the first time,h setup.exe does not select everything by default. Only the minimal base packages from the cygwin distribution are installed by default. When running setup.exe, clicking on categories and packages in the package installation screen will provide you with the ability to control what is installed or updated. Clicking on the "Default" field next to the "All" category will provide you with the opportunity to install every Cygwin package. Be advised that this will download and install hundreds of megabytes to your computer. The best plan is probably to click on individual categories and install either entire categories or packages from the categories themselves.


If ssh isn't in the default install, rerun the installer.


----------



## Brin

Okay, Able to install ssh along with some other things... which got installed

So I try to use the same command and Im able to login to my shell account. Except, Im not connected to it using the port that I had specified. Could it be that the ports are already in use so that I get a different port? I mean, the ports that I get are sortta close to the one I was trying to connect to...



When I try to use localhost:connectedport I can't use it as a proxy...It says "Connection refused" I am on a wireless network which Is kind of messed up so that my ip on my little network and the main network im connected to is the same...

Maybe a problem there, so, if I plug my laptop into the LAN outlet it might work?

Well, I think we're almost there--Thanks much!


----------



## Brin

Eh?


----------



## jiml8

Brin said:


> Okay, Able to install ssh along with some other things... which got installed
> 
> So I try to use the same command and Im able to login to my shell account. Except, Im not connected to it using the port that I had specified. Could it be that the ports are already in use so that I get a different port? I mean, the ports that I get are sortta close to the one I was trying to connect to...


Don't worry about the internals. If you are connected that is all you need to worry about.



> When I try to use localhost:connectedport I can't use it as a proxy...It says "Connection refused" I am on a wireless network which Is kind of messed up so that my ip on my little network and the main network im connected to is the same...


I do not understand this paragraph. If you wish to have me comment on it you need to be specific. From where to where are you trying to use localhost:connectedport? Connection refused means wrong port or no server running, usually. What is your little network? What is the main network? What command did you run?

Please avoid posting screenshots; I couldn't read the ones you posted without considerable squinting and getting close to the screen.


----------



## Brin

I was testing the socks5 server on FreeCap. After I connect to my shell account using ssh -D 8128 

I use the "netstat" command from my computer to see which port I'm actually connected on because it never is the port that I choose...

I then see the port, 1093 (example) and then I add it to my FreeCap proxy list.

I then click on "test proxy" and it says connection refused on localhost:1093.

What I mean by saying little network was that I'm connected to the internet through a WAP therefore ports are messed up and you cant access my computer through WAP. (Wireless Access Point)

What could I be doing wrong?

thanks--


----------



## jiml8

You are making this much too complicated. Forget netstat. Forget internal port assignments. Let the system handle those. 

Is Freecap the server you want to connect to?

ssh -D 8128 is a syntax error and won't be accepted.

On what application are you clicking "test proxy"?

If you aren't clear, I can't help you. The syntax you want is ssh -D port [email protected]


----------



## Brin

Freecap is a program that you can use certain programs through using a socks5 proxy. 
You add the program (ex, IE) and then add the proxy server. I try to test the proxy server by clicking the test button on the program Freecap but it says connection refused.

I do use the syntax ssh -D port [email protected] 
I type this syntax in Cygwin
Then I put in my password and I'm connected to my shell account

However, when I try to use my socks5 server as if its localhost: port
it doesnt work?


----------



## neaj

I'm also trying this with no success.

I run this:
$ ssh -vvv -ND 9999 [email protected]

Firefox is configured to use localhost:9999 as socks proxy.

Each time I attempt to load a page in Firefox, ssh displays debug messages as follows:

"""
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug2: fd 6 setting TCP_NODELAY
debug2: fd 6 setting O_NONBLOCK
debug3: fd 6 is O_NONBLOCK
debug1: channel 2: new [dynamic-tcpip]
debug2: channel 2: pre_dynamic: have 0
debug2: channel 2: pre_dynamic: have 207
debug2: channel 2: zombie
debug2: channel 2: garbage collecting
debug1: channel 2: free: dynamic-tcpip, nchannels 3
debug3: channel 2: status: The following connections are open:

debug3: channel 2: close_fds r 6 w 6 e -1 c -1
"""

However no page loads. Firefox just stops loading, no message.


----------

