connect to drive through ssh hops

112 views Asked by At

I am trying to connect my hdd that is installed on my raspberry pi over the internet. I have a server somewhere that is accessible through ssh that I can use as a hub.

A (home) <----> B (server) <----> C (pi)

I can create a tunnel from the server B to the pi through a reverse tunnel like this:

ssh -f -N -R 10000:localhost:22 user@remoteserver

So now I can connect from home to server B, and then to the pi. But I want this in one step, and with sshfs. So How can I use sshfs such that it uses this tunnel and connects home to the pi?

edit: I can probably mount the pi drive on system B, and then mount this again on system A, but would this be significantly slower, or bad for some other reason?

1

There are 1 answers

3
Khoyo On BEST ANSWER

Use ssh -o ProxyCommand='ssh user@remoteserver nc %h %p' user@yourpi to get SSH access through your server.

I'm not sure if sshfs recognize the -o ProxyCommand option from the cli (and can't test it right now), but you can try.

The other way is to edit your .ssh/config file and add:

Host pi
   ProxyCommand ssh user@remoteserver nc -q0 %h %p

And then to simply use sshfs user@pi[:directory] mountpoint

All this is assuming you have netcat (nc) installed.