If i'm connected to a VPN on my main machine, then ssh into my pi is there a way to share that VPN connection with the pi without having to literally install and set up said VPN on the pi?

  • ssh has features to tunnel/redirect ports. you could connect to a stream and then pass it on to the pi - essentially the pi would host again as if it were a port on localhost and another application could connect to it. a fairly common use is to tunnel vnc through ssh (although this is the reverse of what you'd be doing)
    – Abel
    Oct 3 at 16:58
  • not Raspberry Pi specific ... the question is about linux, so it does not belong here
    – jsotola
    Oct 4 at 0:06

Yes you could either tunnel specific ports that you want to use or use the OpenSSH SOCK5 proxy which allows you to share all TCP networking with another machine over a SSH login.

However normally -D on openssh forwards a SOCKS proxy to the destination so if you wanted to do it in reverse then you'd need to share your local boxes port 22 (SSH server) then with a reverse tunnel and then you can login from the remote box to your local and create a SOCKS5 proxy..

For simplicity I'll assume that both are running Linux/RPIOS etc.

From your local box you need to forward that boxes sshd port (22) to the remote raspberry PI.

e.g. This creates a port 2222 on the localhost of raspberry.local which tunnels back to your local machine.

ssh -R 2222:localhost:22 pi@raspberry.local

This will also give you a login prompt on the raspberry.local on that session type the following command. Where is a valid user on your local box. e.g.

ssh -D 8888 -p 2222  <user>@localhost

Now if all the authentication worked etc. You should now have a localhost:8888 on your raspberry pi which when used with SOCKS5 proxy capable tool will be able to access the network via your local boxes network.

Just remember that as soon as you logout either of the ssh sessions we've created above the proxy will fail to connect.

I can recommend tproxy (Transparent proxy) for using programs over SOCKS5 for CLI programs. Firefox is very easy to configure for SOCKS5.

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.