I am trying to set up an SSH tunnel with a SOCKS proxy in Firefox, so I can surf the internet securely from public wifi. Both client and server are running Ubuntu 12.04 LTS.

After setting up port forwarding on my router (port 8888 forwards to port 22 on my server at home, at least for this example), I am able to log in via ssh normally using the command:

ssh -p 8888 user@hostname

However, when I follow the "standard" directions for setting up the tunnel, I cannot connect. The directions tell me to use this command:

ssh -D 8888 user@hostname

But all I get is a connection timeout:

ssh: connect to host hostname port 22: Connection timed out

I haven't found any other helpful posts on here (or elsewhere). Any suggestions or ideas? I already added the following line to /etc/ssh/sshd_config on the server and restarted sshd:

AllowTcpForwarding yes

Same result. Suggestions are greatly appreciated.


You seem to have mixed up what exactly happens here. ssh -p will tell the ssh client on which port the server is listening, and -D will tell it on which port it should listen locally as SOCKS proxy.

You should use it like this:

ssh -p 8888 -D 5115 user@host

Test it with curl like this:

curl --proxy socks5h://localhost:5115 http://private.example/contacts.html

Source: http://blog.sanctum.geek.nz/ssh-socks-and-curl/

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.