User avatar
Posts: 1834
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Tunneling proxies via ssh

Thu Mar 05, 2015 4:20 pm

I want to connect my RPi to the internet through an SSH proxy server, but I'm struggling a little.

Here is my scenario. I have 3 machines, let's call them A, VM & RPI.
A is a remote linux machine on the internet that can freely access the internet.
VM is a virtual Ubuntu machine on a PC that cannot access the internet except by connecting to machine A via ssh.
RPI cannot access the internet or machine A, but it is directly connected to the PC VM is running on.
VM can access RPI via ssh, but RPI cannot access VM due to a firewall.

What I want to do is to allow RPI to access the internet via A.

So far I have been able to establish A as a proxy server via ssh using:
VM# ssh -D 1080 [email protected]_ip
So now I can set http_proxy on VM to socks5:A_ip:1080 and VM can now access the internet via the proxy server on A.

Also I have connected RPI to VM using a reverse tunnel.
VM# ssh -fN -R 7000:localhost:22 [email protected]_ip
RPI# ssh [email protected] -p 7000

But how can I join these 2 connections together at VM to allow RPI to use the proxy server on A?

Do I have to create a proxy server on VM too?
Or tunnel port 1080 from RPI to VM?
I have also read about the need to enable gateway_proxies in ssh to allow external clients to use the same proxy tunnel, but I'm not sure if or where this should be set.
PINN - NOOBS with the extras...

Return to “Networking and servers”