|
In this modern world, a computer is rarely an island. There is often a file(s) one wants to use from a remote system. Sure, you can use the web to download remote files using a browser, but that is a one-way trip (download only). What if you want to share files (download and upload) transparently as if it were just an extension to the filesystem itself?
Early Windows, Mac & Unix had their respective file sharing protocols, but for the most part they didn't share between OSs. Fast forward to the early 2000s and Macs figured out that having SMB (Windows file sharing) support helped sell Macs into Windows shops. Linux used NFS (Network File System) natively, but could also speak SMB, and AFP (Apple Filing Protocol) with some configuration.
But all of that took time, and for the most part was still silo-ed by OS. SSHFS is an extension to SSH created in 2005.
SSHFS provides transparent Remote File system access with minimal configuration and setup.
SSHFS breaks the Silos of proprietary OS file sharing. Since it is an extension of SSH, it has been implemented on nearly every OS.
Since it is an extension to SSH, it is much easier to install/setup than, say, Samba. There are no additional accounts to configure, no additional daemons to be run, and it utilizes the encrypted transport of SSH, so it is secure.
SSHFS is a network file sharing client, which communicates with an existing SSH server on a remote host (such as a Raspberry Pi). It uses FUSE (File System in Userspace) which allows non-privileged users create their own file systems without kernel permissions.
FUSE was implemented as part of the Virtual File System (VFS) in the Linux 2.6.14 kernel, with libfuse being the user space component.
The FUSE architecture allows other file system support without requiring kernel support.
A client (SSHFS) and a server (typically sshd with SFTP support). That's it!
If you are accessing a remote server via SSH, then no additional ports on the firewall are required to run SSHFS.
Just about everything except your iPhone. And even that is supported if you are comfortable jail breaking your iPhone first.
SSHFS is a FUSE filesystem client, that is available on most distributions. Use your package manager to install it.
Debian/Ubuntu
sudo apt-get install sshfs
Redhat/CentOS
sudo dnf install sshfs
Alpine
sudo apk add sshfs
Arch/Artix
sudo pacman -S sshfs
OpenWrt
opkg update
opkg install sshfs
FreeBSD
# install the package
pkg install fusefs-sshfs
# load kernel module for FUSE
kldload fuse
There is a native ChromeOS application, SecureShellApp, on Google's WebStore. Not only is it a ssh client, but also a SSHFS client. Mounted remote_hosts can be managed by the ChromeOS Files App.
Modern Chromebooks not only run ChromeOS, but also support Android apps, as well as Linux, via LXD (Linux Containers). Both support SSHFS.
Android has an app for that, EasySSHFS. It is available on Google Playstore.
SSHFS is also supported on Windows 10, via WinFCP and SSHFS-Win. There is an excellent Install Tutorial by Zora Lab.
They also have a good how-to on using SSHFS-Win.
MacOS X, being a BSD-based system, should make it easy to install. Like Windows, one must install Fuse for MacOS X before installing SSHFS. It is supported on Intel-based Macs 10.15 and later. Given some time, I am sure it will also support Arm-based Macs as well.
Refer to the above information for your OS/Platform.
Discuss the following:
Since the FUSE system does not require root privilege, it is possible to mount a remote file system as a regular user. In Linux, the command to mount is (1):
sshfs remote_user@remote_host:path local_path
cd
# create a mount point
mkdir Docs
# mount the remote host on the mount point
sshfs demo@netsig.makiki.ca:Docs Docs/
It is good hygiene to unmount remote drives that are no longer in use. In Linux this is done with the fusermount
command.
fusermount -u Docs/
Use the -d
option to enable debug, and see more of what is going on with sshfs
.
Now that you have SSHFS installed, mount a remote file system (e.g. your local Raspberry Pi). Use the Tutorials (above) if you aren't using Linux.
Discuss the following:
Besides the advantages of ease of setup, and cross-platform compatibility, there are additional benefits to using SSHFS:
But like all things, there are some downsides as well:
SSHFS is an excellent solution to file sharing, which is much easier to setup than other network file systems. In addition, it has cross-platform compatibility, while using an encrypted stream, thanks to its ssh
roots. So, go forth, and remote mount, using the simpler, more secure, and easier to use SSHFS.
1. If using individual ssh key files for different remote hosts, create a .ssh_config
file with an entry(s) similar to the following:
host example_host
Hostname example.com
IdentityFile ~/.ssh/privatekeyfile
IdentitiesOnly yes
User example_user
Port 22
10 January 2021
Updated 29 Jan 2021