Although SSHFS is easy to install and use, it can be confusing to set up when you want it to automatically mount a server file system after booting up.
I spent an entire afternoon setting everything up for one directory on my DigitalOcean droplet. I know I was being overly cautious, but I don’t like doing things multiple times due to idiotic mistakes on my part.
I have both Windows 10 and Linux Mint on my web development workstation, the laptop I use every day. I rarely use Windows for anything. In fact, over the last few months, I’ve only intentionally booted into it for the Windows updates.
I have Ubuntu running on my DigitalOcean droplet. For SSH access, I disabled root logins and set up public key authentication for my user names with ssh-keygen. I had to install SSHFS on my laptop using:
sudo apt install sshfs
Unlike WebDAV, I didn’t have to do anything else on the server itself. I already had the user name directories set up for other reasons.
First, I had to create the mount point on my laptop:
sudo mkdir /mnt/mydir
Then I had to edit the /etc/fstab file:
sudo nano /etc/fstab
The line I had to add to the end of the file looks like this:
email@example.com:/home/myuser /mnt/mydir fuse.sshfs defaults,_netdev,allow_other,compression=yes,port=NNNN,identityfile=/home/myuser/.ssh/id_rsa,uid=1000,gid=1000 0 0
To understand what all that means, you need to read the mount, fstab and sshfs manual pages. I use a non-standard port number for SSH. If you use the standard port (22), you don’t need to specify it. The UID and GID numbers are for the first user name on my laptop. Just use “id” on the command line to find the right number.
After I boot up, and before attempting to use the mount point for anything, I check it using the file manager. I wait at the login screen for up to a minute to make sure it’s connected to the internet before continuing. If I log in and there’s no network connection (I use Wi-Fi), I’ll reconnect and reboot. It doesn’t happen often (I don’t have to reboot often). I rarely power down.
I use my SSHFS “share” to update scripts and Nginx configuration files. It’s far easier to do it this way than it is to make changes, upload the files, run the scripts and then download the results. I only have to use an SSH connection to run single commands. If I could run those commands any other way, I would.
I don’t have everything I want running through the SSHFS mount point set up yet, but I should be done with it soon. It certainly makes things easier. WebDAV requires a web server while SSHFS only needs a file system accessible with the SSH protocol. I use WebDAV for my password manager, which I can access with my laptop (KeeWeb) and my cell phone (Keepass2Android Password Safe).
SSHFS is the better choice for web development. At least, that’s what I think about it.