2

I am trying to reach an HTTP(S) website from my device's browser. My Device can get to that website only through a double SSH tunnel.

Using this technique, I'm able to set up my Firefox browser to successfully proxy through an SSH tunnel on a server of mine called SERVER1.

However, SERVER1 can't get to the website that I need. Luckily, SERVER1 can SSH to another SERVER2 who can.

Now, I could run:

SERVER1 $ ssh -D 12345 myuser@SERVER2

and create yet another tunnel from SERVER1 to SERVER2, but I'm not clear on how to do the "firefox" part without firefox on SERVER1.

On top of that, the website is on a non standard port (let's say 8765) so I'm not sure the export http_proxy would work.

How would I go about it? Thanks

1
6
+50

Duplicate of How to chain SOCKS proxies?

To chain proxies: https://superuser.com/a/843766/19867

ssh -tt -v -L1234:localhost:12345 user@server1 ssh -t -D 12345 user@server2
1

First setup a ProxyJump chain to the target server. this may look like this in your ssh-config

Host SERVER2 
ProxyJump SERVER1

You can chain more jumphosts by using ProxyJump jumphost1,jumphost2

Then use ssh -D 1234 SERVER2 and set localhost:1234 as socks Proxy in the local firefox.

An alternative is to use ssh -L to forward the HTTP port, but can be more complicated when the server uses the hostname for virtual hosts or selection of a TLS certificate.

The nice thing about ProxyJump is, that you do not need to think about if when you set it up and all ssh options will work as usual and you can use the hostname as if you could reach it directly.

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.