Miguel
Miguel

Reputation: 7627

Mounting a remote file system (sshfs) through an intermediate machine

The situation:

What I want to do:

Complications:

How can this be done?

Upvotes: 5

Views: 1413

Answers (2)

Stefan Steiger
Stefan Steiger

Reputation: 82326

Theoretically, mount machine 3 on machine 2 via sshfs, then mount the sshfs directory of machine 2 in machine 1.

As no-privilege user, you can only create folders in your home directory.

So theoretically, this should work (but be slow):

machine2:

mkdir /home/<username>/sshfs
sshfs <machine3_username>@machine3:/ /home/<username>/sshfs

machine1:

mkdir -p /mnt/sshfs
sshfs <machine2_username>@machine2:/home/<username>/sshfs /mnt/sshfs

Upvotes: 1

Tomek Rękawek
Tomek Rękawek

Reputation: 9304

You may use ssh to forward port 22 from machine3 to machine1 via machine2, like

user1@machine1:$ ssh -L 2222:machine3:22 user2@machine2

After that configure sshfs on machine1 to use localhost:2222 port (in the second terminal tab):

user1@machine1:$ sshfs user3@localhost:/some/machine3/dir /some/local/dir -p 2222

Upvotes: 9

Related Questions