I need to forward internet traffic from a local machine to a remote machine, routing traffic through an intermediary SSH server on the way. The remote machine is firewalled and running a SOCKS5 proxy which accepts incoming connections on, for example, port 9999. The local machine is also firewalled and using a socks5 proxy via an ssh tunnel to a remote SSH server.
I'm able to accomplish this using the browser on the intermediary server configured to use the remote proxy, but I want to be able to do the same thing except using the browser on the local machine instead.
I can point my browser to the local socks5 proxy to forward the traffic to the SSH server, using "SSH -D [PORT] -C [SSH ADDRESS] -l [username]" to create the proxy and connect to SSH server. But what I haven't figured out is how to tunnel the traffic from the SSH server to the remote proxy. I'm confused by the syntax of SSH and the -R -L ProxyCommand and Connect commands.
I essentially need this:
|(L)Browser|->|(L)SOCKS5|-->|SSH server|-->|(R)SOCKS5|->|(R)Machine|-> internet