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?
Best Answer
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:This way after you logout the parent of your sshfs process will become the process with id 1 and your mount will stay up.