A small trick of using shfs:
shfsmount -ps –cmd=”ssh -l username FirstMachine login2″ username2@SecondMachine /path/to/mount -o cachesize=256
My goal: from my home Linux box, I want to mount the remote filesystem on SecondMachine by using the shfs kernel module. However, SecondMachine is behind of firewall, the only way to connect to this machine is to hop from the FirstMachine.
From the manual page of shfsmount, I figured out that –cmd=”foo” provides an alternative to the standard ssh tunnel, and here “foo” is ssh -l username FirstMachine login2, where the first part “ssh -l username FirstMachine” is self-explanatory, “login2” is actually a piece of script locates on the FirstMachine, with the content like this:
ssh -l username2 SecondMachine /bin/bash
So login2 actually provides a usable shell as well as an ssh connection to be used by shfs on my home Linux box.