1

I've got two things working, but I'd like to do a third thing: I'd like to use a remote Raspberry Pi (running Raspbian), which has a dynamic IP, as a SOCKS proxy for surfing. But I can only access this Rpi through a reverse tunnel.

So I have:

  • my local desktop (behind a dynamic IP)
  • a Raspberry Pi in another country (behind a dynamic IP)
  • a dedicated server with a fixed IP

I've got full control of all these machines, but not of the routers in front of my local desktop and remote Raspberry Pi.

The following works fine:

ssh -D 5222 [email protected] -N [email protected]

This allows to surf using, say, Firefox or Chromium, as if I was surfing from my server at the IP aaa.bbb.ccc.ddd (all I need to do is configure SOCKS to use localhost with port 5222).

The following also works fine:

ssh -t [email protected] "ssh rspi@localhost -p 32402"

The Raspberry Pi use autossh to always establish a reverse tunnel to the server with a fixed IP (in this case I know it's on port 32402: it tells me about which port it's using when the port changes so no issue there).

So with that "double ssh command" I can control my Rapsberry Pi from a terminal from my local desktop, by transiting through the server with a fixed IP.

So far so good. Now knowing that these two work fine, I'd like to know what's the magic incantation to allow me surf using the remote Raspberry Pi as a SOCKS proxy (keeping in mind I always know the port on which the Raspberry Pi establishes the reverse SSH tunnel on)?

Is there any modification/configuration I should do on either the remote Raspberry Pi or the dedicated server or is it just a matter of setting things up correctly from my local desktop?

1 Answer 1

3
desktop$ ssh -J [email protected] -D 5222 -p 32402 rspi@localhost

Hum that's actually all that's needed.

If your ssh is too old for a -J command, you can replace the line above with those two commands instead (in two terminals or with options like -f -N to put the first in background ):

desktop$ ssh -L 32402:localhost:32402 [email protected]
desktop$ ssh -D 5222 -p 32402 rspi@localhost

The -J option is just a shortcut to avoid having to run the first command in the 2nd older method.

3
  • +1 thanks a lot, this worked fine on the first try. I'll try to make this work with autossh which is greatly helping with connection dropping too often. If I can't get it too work, I'll come back one of these days with another question! Nov 7, 2017 at 23:20
  • But this is for a forward "-L" tunnel (forwarded to the given host and port on the remote site) --- not a reverse "-R" (connections to the given TCP port or Unix socket on the remote (server) host are to be forwarded to the given host and port, or Unix socket, on the local side) tunnel which the question title asks about. Dec 19, 2018 at 20:22
  • @DavidTonhofer the reverse tunnel is part of the overall setup, and already worked out by OP, the actual question is "I'd like to know what's the magic incantation to allow me surf using the remote Raspberry Pi as a SOCKS proxy"
    – A.B
    Dec 19, 2018 at 20:33

You must log in to answer this question.

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