This should be a simple issue to solve, but for some reason it's not working for me.

ssh vps works just fine (I use authentication keys)

I set up the tunnel with the command:

ssh -C2TNv -D 8080 vps

I then modify Firefox network settings:

  • manual config
    • http proxy: localhost, port: 8080
    • use this proxy server for all protocols
    • SOCKS v5
  • about:config
    • network.proxy.socks_remote_dns: true

Terminal output:

$ ssh -C2TNv -D 8080 vps
OpenSSH_6.0p1, OpenSSL 1.0.1a 19 Apr 2012
debug1: Reading configuration data /home/ting/.ssh/config
debug1: /home/ting/.ssh/config line 47: Applying options for vps
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to vps.server.com [] port 22.
debug1: Connection established.
debug1: identity file /home/ting/.ssh/id_rsa type 1
debug1: identity file /home/ting/.ssh/id_rsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1 pat OpenSSH_5*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 zlib@openssh.com
debug1: kex: client->server aes128-ctr hmac-md5 zlib@openssh.com
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA <removed>
debug1: Host 'vps.server.com' is known and matches the RSA host key.
debug1: Found key in /home/ting/.ssh/known_hosts:10
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/ting/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Enabling compression at level 6.
debug1: Authentication succeeded (publickey).
Authenticated to vps.server.com ([]:22).
debug1: Local connections to LOCALHOST:8080 forwarded to remote address socks:0
debug1: Local forwarding listening on ::1 port 8080.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on port 8080.
debug1: channel 1: new [port listener]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.

I then try visiting a site using Firefox, SSH output:

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

Despite the proxy seemingly working, visiting any site with Firefox just returns with the error "The connection was reset".

  • have you tried curl. $curl --socks4 blah
    – barlop
    Apr 26 '12 at 23:39

Your SSH command with -D is fine (so the SOCKS will tunnel it's just the connecting to the SOCKS via HTTP, that you have to sort out)

I get good output with

curl --socks5 http://blah

but I get the same wrong output you get if I do

 curl --proxy http://blah

So, firefox is connecting as if it's an HTTP Proxy

Looking at the firefox window

manual config YES

you said you ticked "use this proxy server for all protocols" That is a totally wrong move! You want to enter a SOCKS proxy, and if you do that then the SOCKS box get nulled/greyed out and you can only enter an HTTP Proxy.

So don't tick that.

And do, enter the socks proxy ip.

and remove where it says no proxy for,localhost . if it says that, which is default.

  • 15
    Thanks for the answer. However I got it working by clearing out everything in Firefox's proxy config screen except the SOCKS Host field. If I added anything into the HTTP Proxy field it stopped working.
    – wting
    Apr 27 '12 at 0:29
  • @wting or @barlop, I couldn't ask for a description of the ssh flags -C2TN could I?
    – Mike H-R
    Apr 21 '14 at 21:33
  • 1
    @MikeH-R i'm not that familiar with it but it'd break down to -C2 -T -N -v. looking at man ssh, it looks like -C2 is to do with compression -C does compression and it mentions inclusion of a level so eg. -C2 which he did. -T or -N or both -T and -N are to do with making the ssh simpler in the sense that, normally when you ssh even with port forwarding, it opens a cmd prompt and you have a shell so what he did there stops that from happening so he just has the port forwarding feature he wants without the shell. and -v is verbose. (though if you want verbose -vvv i.e. 3 of them is better)
    – barlop
    Apr 21 '14 at 21:41
  • Thanks @barlop, you cleared it up a little from the docs, much appreciated.
    – Mike H-R
    Apr 21 '14 at 22:12
  • @MikeH-R no prob I was wondering at the time what that was too though didn't check at the time! I was still curious when I looked it up now!
    – barlop
    Apr 21 '14 at 22:34

To check connection via curl you may also use flags -I -v (to get only HTTP headers and to get output more talkative).

If these flags selected and curl connecting - you'll see in output string like:

* Rebuilt URL to: http://www.google.ru/
*   Trying ::1...
* 87
* 245
* 198
* 44
* Connected to localhost (::1) port 8080 (#0)

If cannot get connection:

* Rebuilt URL to: http://www.google.ru/
*   Trying ::1...
* connect to ::1 port 8080 failed: Connection refused

In another terminal's tab with ssh connection you'll something like this:

debug1: channel 2: new [dynamic-tcpip]
debug1: channel 2: free: direct-tcpip: listening port 9999 for port 80, connect from ::1 port 55034 to ::1 port 8080, nchannels 3

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.