What are the difference between nfs over ssh and sshfs?
Solution 1:
As the name implies, NFS is a network filesystem, i.e., a protocol designed for accessing files on a filer. As it consists of multiple services and uses multiple ports, it can appear a bit clunky and difficult to set up (firewalls...) but NFS is very reliable and when you know when and how to use it, it's probably the best tool for the job.
SSHFS, on the other hand, is a (userspace) filesystem layer stacked on top of SSH, which is not a filesystem protocol but a remote shell protocol. Therefore, it may not be as reliable as NFS or lack features. For example, every proper filesystem takes metadata into account when working with files. At least the "modified" date is always preserved when copying files around, no matter if the target is an NFS share or a USB drive with an NTFS partition. Unfortunately, this information may be lost if you're copying files to an SSHFS share.
SSHFS is great when you just want to open some files on a remote server and that's all. Assuming you have a password-less key set up, all you need to do is type "ssh://myserver" in the address bar of your favorite file manager (like Caja) and you're there. That may be convenient if you're not home but want to check some documents on your home computer. But don't copy important files or photos onto your home computer that way unless you don't care that you won't be able to find or sort those files by date anymore.
If you need a reliable filesystem, if you actually need to work with it and don't want to lose anything, go with NFS. Note that NFS was designed to be used in a static environment, not through a temporary connection that you might pull the plug on. If you have an NFS share mounted and the connection to the server goes away, the mount freezes (so do all programs trying to access that mount) until the server comes back in order to prevent data loss. If you're using NFS over an unreliable network like the Internet, you should probably use the "soft" option to tell the system that you'd prefer to lose open files on disconnect rather than having your system freeze.
Solution 2:
SSHFS is using SFTP protocol, which is subsystem of SSH server. This technique is using also FUSE to make the filesystem accessible from user-space program.
NFS4 over SSH is using native NFS protocol forwarder through SSH tunnel.
For user, it can sound similar, but difference is in the main protocol (SFTP x NFS) which handles IO for you.