5

The situation:

  • I am working from machine1, where I have root access. From machine1 I can access machine2 (where I am a user with no privileges) through ssh.
  • machine3 (also user with no privileges) is not directly accessible from machine1. I need to use an ssh connection from machine2 to access machine3.
  • In short: machine1 can ssh into machine2 but not into machine3. machine2 can ssh into machine3.

What I want to do:

  • I want to use sshfs to mount on machine1 a local (own) directory located on machine3.

Complications:

  • sshfs is not available on machine2.

How can this be done?

Miguel
  • 7,497
  • 2
  • 27
  • 46

2 Answers2

9

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
Tomek Rękawek
  • 9,204
  • 2
  • 27
  • 43
1

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
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
  • I forgot to say sshfs is not available on **machine2**. – Miguel Nov 13 '13 at 10:10
  • @Miguel: Then Tomek Rękawek's answer should work. You may have to copy id_rsa.pub & private to machine1 and create a user account there, if you use ssh with private-public-keys instead of password. – Stefan Steiger Nov 13 '13 at 10:18