I am trying to use my server as a "proxy" with ssh. However, setting up tunneling with

ssh -D localhost:8000 user@myserver

does not work.

I tested this on various machines with ssh and putty - It connects just fine, but when I set my browser settings accordingly, I just get an error "Connection has been reset". I tried monitoring the traffic with wireshark, but I didn't even see some tunnel-traffic. I explicitly set AllowTcpForwarding to "yes" but I still can't use the tunnel.

When running ssh in verbose mode, I don't get any errors but

debug1: Connection to port 8000 forwarding to socks port 0 requested.
debug1: channel 3: new [dynamic-tcpip]
debug1: channel 3: free: dynamic-tcpip, nchannels 4

What am I doing wrong?

  • 2
    I suspect that you config your browser at HTTP Proxy line instead of SOCKS host. – quanta Sep 15 '12 at 13:32
  • I always made sure to set the SOCKS option, no matter which browser I was using. – s1ck Sep 15 '12 at 13:45
  • Can you do tcpdump at the server (root/sudo access)? Pick an IP address reveal page, get it's IP address, watch that IP for traffic at the server, and try to visit it from your browser. FYI, the OP's ssh command works for me, from my desktop to my remote server. – Skaperen Sep 15 '12 at 19:26
  • Hi! I already tried capturing with wireshark and it turns out that data never arrives at the server. When loading pages with the proxy activated, just no packets are sent at all. How could that be? – s1ck Sep 23 '12 at 18:17

It's an old thread, but I think it's worth posting possible solution.

I had the same issue with several browsers and it turned out to be configuration issue. If that's the case, the following command should work and show IP address of remote machine:

links -socks-proxy localhost:8000 www.myipaddress.com

First comment on the question is correct in that browser might try to use HTTP proxy instead of SOCKS proxy, in which case I see exactly the same output from ssh as in the OP's post. And although I did set SOCKS proxy the problem was that I didn't unset HTTP proxy. Once that was done, everything started working as expected.

  • 3
    I had the same problem. No matter what I did, the accepted answer didn't work. Your additional answer solved everything for me. Listen up everyone! Don't forget to UNSET the other proxy settings, as well as the "No Proxy for..." addresses like this: imgur.com/h4Q28ek – 0xSheepdog Aug 6 '14 at 2:52
  • 1
    This took me days to figure out! UNSET other proxies, only SOCKS – G-. Sep 12 '18 at 17:19
  • how to unset the other proxies for firefox? – StephenBoesch Aug 3 '19 at 22:00
  • @javadba, clear proxy address field. I think port number can stay, but you can clear it too. – xaizek Aug 5 '19 at 12:50

The correct command is:

ssh user@server -D 8000

In the case you still can't connect check if another process is using this port. The most easy way to do this is with:

netstat --listen |grep 8000

If that is the case just use another port.

  • this doesn't work either. "Connection Reset", same thing – s1ck Sep 15 '12 at 13:15
  • will update my answer – Lucas Kauffman Sep 15 '12 at 13:17
  • I made sure to use unused ports. I tried different ones, still the same. I am also running the ssh client as root, so permissions are not a problem, either. – s1ck Sep 15 '12 at 13:25
  • you shouldn't be running it as root for other reasons, but I'm really baffled a bit. Do you have any iptables running on your server? – Lucas Kauffman Sep 15 '12 at 13:31
  • No iptables whatsoever, neither on the server nor client-side – s1ck Sep 15 '12 at 13:45

I had the same issue, my fix is to add -g option to the command:

$ ssh -D 12324 localhost:8000 user@myserver -g

Also enabling in sshd_config on the ssh server:

PermitTunnel yes

And of course:

service ssh restart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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