To heck with NFS, instead let’s have autosshfs

NFS has been around since the dawn of time. It’s old, clunky, but it works. At least it used to. At home I’ve been using it to keep all my files on my server which regularly gets backed up. A couple weeks ago, I did an update to both server and desktop and that’s when the problems started. First Chrome was acting up, not loading pages and all. Thought it was the typical NFS stale lock, so after rebooting everything, the problem was still there. Not using NFS, the problems went away.

So I started looking at how to fix NFS and figure out what broke. After spending a couple days debugging I figured this isn’t worth my time. So I looked into SSHFS which I’ve used lots before. Combine that with AutoFS and we’re golden. There were some tutorials that I looked at (this was a particularly good one). There was even an elaborate github script someone came up with. I came up with a much simpler version:

Edit /etc/auto.master to have:
/mnt/sshfs /etc/auto.sshfs --timeout=60,--ghost

Then put in /etc/auto.sshfs (note that it is all one line, there should be no space after the commas):
* -fstype=fuse,rw,nodev,nonempty,noatime,allow_other,
max_read=65536,follow_symlinks,uid=$UID,gid=0,idmap=user,
UserKnownHostsFile=$HOME/.ssh/known_hosts,
IdentityFile=$HOME/.ssh/id_rsa :sshfs\#&\:

Now just restart the service with something like:
sudo service autofs restart

This should make it so that when you do something like ‘ls /mnt/sshfs/user@hostname’, it will automatically try to use your authentication and create a SSHFS mount. If you use just the hostname, it will try to log in as root.

I’m planning on creating a symbolic link from my home directory to the sshfs mount on my server. Then I won’t have to worry about NFS ports being open and all sorts of other issues. Perhaps there may be problems with file locks certain programs use, but I’ll deal with them on an as-needed basis.

PS: If things aren’t working, you may need to have the user in the ‘fuse’ group (doubt it). Also, the /etc/auto.sshfs file should not have any execute permissions on it. If you’re still having trouble, try starting autofs with ‘sudo automount -f -v -d’ to see what the errors are.

Liked it? Take a second to support me on Patreon!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.