3

I tried to run sshfs through ssh in one command.

For example, if I do :

$ ssh user@host
user@host$ sshfs host:/src /target

Everything is ok. Now, if I tried this in one command :

ssh -t "sshfs host:/src /target"

But not mounted point. By using sshfs debug option, it seems volume is mounted and immediately unmounted when ssh connection ended.

I also tried to run sshfs in a login shell, but result is the same when exiting shell :

ssh -t "/bin/sh -l -c sshfs host:/src /target && /bin/sh"

What's wrong ? Is there one another best way?

0

2 Answers 2

4

When you exit your remote shell, all the child processes which you launched through that shell get killed, because the parent (shell) gets killed when you logout.

To avoid that you can use nohup command:

ssh -t "nohup sshfs host:/src /target"

This way after you logout the parent of your sshfs process will become the process with id 1 and your mount will stay up.

3

You should rather use autofs to automagically mount the SSHFS filesystem when someone tries to access that path.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .