Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm using SSHFS mounts from my laptop to a central server.

Obviously, the SSHFS mount is broken after a longer disconnect (eg. during suspend), cause the underlying SSH connection timed out.

Is there a way to get SSHFS mounts surviving long lasting disconnections (> 5 min) or even a re-dialin with a different IP?

share|improve this question

5 Answers 5

up vote 21 down vote accepted

Thanks for the tips of autossh and autofs.

However, for my direct purpose I found a much simpler solution which wasn't documented so well:

sshfs -o reconnect server:/path/to/mount

share|improve this answer
Sweet! This makes me really want to sort out authenticate-on-write : serverfault.com/q/379728/96905 –  Jeff Burdges Jun 17 '12 at 12:39

Autossh automatically reconnects ssh sessions when it notices ssh has died or stopped passing traffic. Since it is just automated ssh, it will work from different IP's and from suspend (even if the laptop wakes up on a different lan).

share|improve this answer

One thing you could do is mount your filesystems via autofs. Autofs is a tool that will mount a filesystem when you to use something in the directory that the filesystem will be mounted to. When it detects activity the filesystem is mounted. When nothing is happening on the filesystem is it unmounted.

Here is a howto I found on google to accomplish this, there where several others.

share|improve this answer

I suspect there isn't, because even if you can configure your SSH client not to drop the connection, the server might be configured to do so after a specified period of inactivity, and you wouldn't be able to override that. Even if you could, if you never resume the connection, the server would be left hanging, and over time that could lead to a significant waste of server resources.

A better technique, I think, is to unmount the filesystem before suspending your computer and remount it when the computer wakes up again. The mechanism for doing so may depend on exactly how you suspend your computer - I use the tuxonice kernel and to do something like this I have a directive like

Unmount /mnt/sshfs

in /etc/hibernate/common.conf.

share|improve this answer

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.

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.