2

I have HostA behind a firewall establishing a reverse ssh tunnel to HostB. I want to setup a proxy on HostB that will forward the connection through the reverse ssh tunnel and out through HostA.

I tried ssh -D 5678 user@localhost -p 1234 yet firefox times out when trying to connect to HostB on port 5678 as a socks proxy. 1234 is the port on HostB where the reverse proxy is setup to HostA. Does anyone have advice on setting this up?

The reverse proxy is setup on HostA as ssh -R 1234:localhost:22 user@HostB

2 Answers 2

2

I tested this on my systems and didn't have any problems.

  1. hostA: $ ssh -R 1234:localhost:22 user@hostb

  2. hostB: $ ssh -p 1234 localhost -D 5678

  3. hostB:

    $ curl http://portquiz.net
    Port 80 test successful!
    Your IP: 66.77.88.159
    
    
    $ curl --socks5 localhost:5678 http://portquiz.net
    Port 80 test successful!
    Your IP: 23.31.31.35
    

Does the curl command work? If so, in Firefox you'll want set HTTP Proxy: localhost Port: 5678 and check Use this proxy server for all protocols.

If the curl command does not work, I would check that iptables and selinux aren't getting in the way. For troubleshooting, I would recommend disabling iptables and selinux on both hosts. This is only temporary and should not be considered a permanent solution.

-1
HostA$ ssh -R 1080 user@HostB
HostB$ curl --socks5 localhost https://example.com

From OpenSSH 7.6

ssh(1): add support for reverse dynamic forwarding. In this mode, ssh will act as a SOCKS4/5 proxy and forward connections to destinations requested by the remote SOCKS client. This mode is requested using extended syntax for the -R and RemoteForward options and, because it is implemented solely at the client, does not require the server be updated to be supported.

Source: OpenSSH 7.6 release notes

You must log in to answer this question.

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