The scenario is That a cloud Ubuntu server is running a Socks5 proxy server on a specified port; on this cloud server :

  • Socks5 server serving on port 1515 (only local connections accepted)
  • SSH is accepting connections from ports 22,33 and 44

What we want is to let any client use "Dynamic port forwarding" ability of SSH to connect to the Socks5 server running on the cloud server to be specific Client is going to use this command :

ssh -D 1080 -N -f [email protected] 

So any application that uses Port 1080 on the client will have it's traffic routed through the SSH connection and then That remote Socks5 server, so the traffic path will be like :

App running on client machine>Client Socks server on port 1080>SSH Tunnel>Socks5 server accepting local connections

I hope I have explained clearly, Thnaks

Edit : I want client to only use -D option and want the server to actually route incoming SSH traffic to another interface or a Socks host

1 Answer 1


Firstly -D 1080 will create a SOCK5 proxy on your localhost and to the remote end of the SSH connection. Which is why it won't forward to the remote SOCKS5 proxy.

What you need todo create a SSH to tunnel that last leg to the tunnel the remote 1515 port so it appears local to your machine..

ssh -L 1515:localhost:1080 -N -f [email protected]

At which point in another window on the local box where you ran the ssh command above..

You should then be able to connect to the localhost:1080 for transparent access to the remote SOCK5 proxy.

See this helpful visual guide to ssh tunnelling here:- https://iximiuz.com/en/posts/ssh-tunnels/

  • This is question is not about port forwarding, sorry for bad explanation Commented Jan 23, 2023 at 14:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .