Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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.

share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.