14

A third-party program will write files to a SSHFS mounted dir. If the internet connection is lost, the third-party program will likely crash (badly), because all programs trying to access such an SSHFS mounted dir in such a state (when there's no internet connection) are put into what some describe as "uninterruptible sleep". SSHFS has an option to auto-reconnect, but this doesn't help, as the third-party program will still hang (and crash) if the connection is lost (even though when the connection is restored, SSHFS will remount the dir). Autofs will not help, basically it's about the behavior of SSHFS when the connection is lost. Why can't it behave like a network shared directory (Samba or other means) and simply return an error sooner rather than... never?

Are there alternatives to SSHFS if SSHFS can't work as described?

Other info:

OS: I'm using Ubuntu Linux (12.04 LTS)

Andrei
  • 483
  • 1
  • 3
  • 11
  • Please explain what exactly you are doing. I imagine you are mounting a remote filesystem using sshfs on a local Linux machine, is that so? Perhaps include your `/etc/fstab`? Have you tried autofs with the `soft` option? – terdon Apr 11 '13 at 16:45
  • Thanks for the update but please include it in your question since not everyone reads the comments. Also include the config files you are using. What is the value for ssh timeout etc? I am not saying I know how the answer, its just that the more information you have in your question, the likelier it is that you will get a good answer. As it stands, it is hard to understand what exactly your setup is. – terdon Apr 11 '13 at 17:17
  • @terdon Thanks, I basically now almost replaced my question entirely. – Andrei Apr 11 '13 at 17:21
  • Much better :). Please also add the OS you are using. Is this Linux, OSX, another Unix? – terdon Apr 11 '13 at 17:49
  • @Andrei I have the same prob on OS X El Capitan. SSHFS is fast when it's working. `-o reconnect` does not solve the issue. `GNU SSHFS version 2.0` installed with Homebrew. – Jonathan Komar Jul 16 '16 at 13:15
  • Could you pass the "ConnectTimeout" parameter to SSHFS, maybe by way of tweeking the ssh config file or specifying a command for ssh including the ConnectTimeout using -o ssh_command=??? – davidgo Oct 05 '16 at 08:35
  • @davidgo you can indeed pass any SSH option to SSHFS, it's simply `-o ConnectTimeout=` – OrangeDog Mar 01 '21 at 16:13

3 Answers3

1

Sad issue. I tried sshfs several times in the past.

As soon as the connection is lost, applications accessing files in the mounted folder freezes and crashes. Even Terminals. BUT the applications don't even know that they are waiting. It's something on the kernel-level that cannot handle sshfs telling them to wait forever... even unmount doesn't work and even freezes sometimes because the mounted folder is locked somehow on the filesystem-kernel-level.

Why doesn't this happen when I unplug a USB drive?

This issue exists for years now ...

Auto-reconnect doesn't help if you just cannot re-establish a connection at anytime. (In my case I have kerberos Tickes running out).

Sorry but I have to state: sshfs is unusable!
(except for cases in which a connection is never lost)

I always end up using scp instead. Sad issue

Rich Michaels
  • 2,841
  • 2
  • 11
  • 20
bugpulver
  • 21
  • 2
1

sshfs documentation suggests the use of the -o ServerAliveInterval=15. This could lead to data loss, but should return an error after 45 seconds of network interruption.

https://github.com/libfuse/sshfs/blob/master/sshfs.rst#sshfs-hangs-after-the-connection-was-interrupted

Saïmonn
  • 386
  • 2
  • 7
0

In short: No - because the freezing is from the application, sshfs failure is graceful - it'll tell the application to wait. - the fact the application doesn't respect this isn't the fault of SSHFS.

The application would do exactly the same, if it was accessing a file on removable storage such as a usb drive, and you removed it. The application needs to capture and handle the timeout events on I/O instead of just getting stuck waiting for the response.

djsmiley2kStaysInside
  • 6,643
  • 2
  • 31
  • 43