A Better Network File System

April 19, 2005

After many years of using Linux, there is still remains one problem that I seem to run into at every turn. Remote file systems. In short, they suck. Recently, I asked around about this topic because I felt like I was missing something. I was thinking that perhaps there is some perfectly elegant file sharing protocol that has somehow escaped my radar all these years. Alas, the responses I got were the expected ones. "Use samba." "You can configure NFS." Forget Samba, forget NFS. Why? Because we already have a better way.

The problem with both Samba and NFS is that they require (a lot of) work to get setup right. There are mappings to deal with, file permissions to configure, and firewalls that try to disrupt the whole episode. To throw more issues into the mix, there is the problem of compatibility between versions (NFS3 vs NFS4, Samba 2 vs Samba 3).

So if I'm complaining, you would that I have a solution to present. I do have one, just bear with me. One of the common responses I get to the question "How do you share files between two Linux computers?" is the terse response "SCP." Okay, so how much of a stretch would it be to imagine one computer performing an SSH mount to another computer?

As it turns out, one team already has, with shfs.

Shfs is a simple and easy to use Linux kernel module which allows you to mount remote filesystems using a plain shell (ssh) connection.

Brilliant! It is the perfect solution since it is already secure, it requires only an account on the remote machine, and all permissions are inherited from the native pam implementation. Forget portmapper, rpc daemons and flaky netbois broadcasts, just use what has been there all along, the grassroots SSH protocol!

Posted at 12:08 AM in Linux | Permalink Icon Permalink

10 Comments from the Peanut Gallery

1 | Posted by Dan Allen on April 19, 2005 at 12:27 AM EST

I just tripped over another project, lufs, that does something similar with virtual filesystems, except it seems to focus on a wider subset of protocols.

2 | Posted by Dan Allen on April 19, 2005 at 02:28 AM EST

Just tripped over another great utility, fsh. fsh is a drop in replacement for ssh when used to execute remote commands. The only difference is that it will reuse a secure tunnel once it has been established. This is excellent for repetitive rsh use such as CVS over ssh.

3 | Posted by Dan Allen on April 20, 2005 at 01:48 PM EST

I just discovered that fsh does have to be installed on both the client and the server to work properly.

4 | Posted by Dan Allen on April 23, 2005 at 12:45 AM EST

Oh, and one other tip. Unless you have been living under a rock for the past year, you should have heard about the fish ioslave for KDE. It is built using the sftp protocol, but also leverages remote execution of commands via ssh to increase efficiency and transparency.

For instance, opening a file using a KDE program via the fish:// protocol allows you to read and write that file as if it were on the local filesystem. If the file is opened using a non-KDE app, KDE will manage that file and upload it back to the server when the application terminates. KDE is very powerful like that.

5 | Posted by Tommy Li on May 28, 2005 at 10:03 PM EST

FISH is different from SFTP. It uses only SSH (compatible with SSHv1). SFTP uses the sftp subsystem of SSH2.

KDE has it's own sftp ioslave. I use sftp.

6 | Posted by Dan Allen on June 15, 2005 at 02:56 PM EST

Thanks for the clarification Tommy Li! I was wondering what the main differences between FISH and SFTP were. I also heard the FISH uses perl if it is available on the remote system to perform more efficient operations.

Does anyone have a link to a detailed breakdown of the two implementations?

7 | Posted by Dan Allen on May 23, 2006 at 11:19 PM EST

I was confused by the similarity in names, but it appears that SSHFS is actually a distinct project that accomplishes the same task as shfs. It appears to be inspired by the aforementioned lufs. The author makes the following claim:

There were some limitations of that codebase, so I rewrote it.

SSHFS boasts the following features:

  1. Based on FUSE (the best userspace filesystem framework for linux ;-)
  2. Multithreading: more than one request can be on it's way to the server
  3. Allowing large reads (max 64k)
  4. Caching directory contents

8 | Posted by dyssident on August 31, 2006 at 04:19 AM EST

Ive had great luck with OpenSSH to share files, SSHFS to mount and Avahi for easy host naming.

Here is a tutorial I did covering something similar with FTP: http://www.ubuntuforums.org/showthread.php?t=218630

9 | Posted by SLX on August 23, 2009 at 08:38 AM EST

Network File System is something other than sharing files between computers. NFS can stream files. You can watch films, music, etc. stored on remote machine, without first downloading them onto your computer.

10 | Posted by sm0ke on June 02, 2012 at 03:04 AM EST

Hi Dan, Your post is rather all by now, did you tried lately NFS4? It isn't the panacea for network data-transport but it works quite well the most of time and if you partner it with AUTOFS you have a great tool in your hands. From my experience SSHFS is only useful as long as you need an encrypted tunnel between two machines but's impractical for mundane data flow tasks -cp, mv, stream, etc.- because the _excesive_ overhead it adds to the local computer as it's needs a lot of CPU to run it. Anyways, NFS4 is good enough for a small cluster of machines because the way it's designed to work, for a larger amount of boxes (+20) and for tigher security Kerberos would be a better solution. Regards!