Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mounting sshfs on unreliable connection

Tags:

sshfs

fuse

I mount remote filesystem with sshfs. If the ssh connection times out it can cause other applications to hang (e.g. vim session with only local file open). It takes ~10 minutes for the system to recover. This happens even if I mount the remote filesystem read-only. Why? Is there a way to do sshfs mount so that it will not cause other applications to hang when using unreliable connection (e.g., wifi)? I don't need something robust, I just need to be able to view files on remote computer, can be read-only.

I use lubuntu 12.10.

$sshfs -V
SSHFS version 2.4
FUSE library version: 2.9.0
fusermount version: 2.9.0
using FUSE kernel interface version 7.18
like image 209
John Newman Avatar asked Jul 16 '13 21:07

John Newman


People also ask

How do I permanently mount SSHFS?

If you want to permanently mount the remote directory you need to edit the local machine's /etc/fstab file an add a new mount entry. This way when your system boot up it will automatically mount the remote directory. To mount a remote directory over SSHFS from /etc/fstab , use fuse. sshfs as the filesystem type.

How reliable is SSHFS?

Yes, SSHFS is safe to use over public Internet. Internally it uses the SSH File Transfer Protocol, which requires an existing SSH session to be set up, so you get all the security benefits of “regular” SSH in terms of authentication and encryption.

Can you access SSHFS mounted files as root?

You can use bindfs + sshfs to access other user files (even root). Firstly you mount your 'root' or any other directory under your user with remapped uid. and then simply sshfs into the directory.


1 Answers

Use -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3

These ServerAlive options cause the I/O errors to pop out after one minute of network outage. Without these options, processes which experience I/O hang seem to sleep indefinitely, even after the sshfs gets reconnect'ed.

like image 123
kubanczyk Avatar answered Sep 21 '22 12:09

kubanczyk