[Mac] Mount HA filesystem with SSHFS (instead of SMB)

SSHFS – remote file system over SSH

This tutorial is for MacOS. You can probably do the same on Linux, but I don’t know about Windows – I don’t use them on desktop, so can’t help.

This tutorial is a bit advanced. If you actually need SSHFS, you probably don’t need this tutorial → but since I’ve already figured it out, I decided to share it for others (and as a future reference for myself as well).

Why you may want this?

  • It mounts a remote filesystem as if it was a normal “disk” (drive, volume) on your Mac.
  • You can use the HomeAssistant’s (remote) files in your regular Finder window.
  • Easy to copy/move/rename files → open config files in your favorite Mac editor.
  • It’s secure (encryption).
  • You can’t use / don’t want to use Samba (for “reasons”).

Why not Samba (SMB)?

What’s required:

  • SSH configured on HomeAssistant (Terminal & SSH addon)
  • MacFuse and SSHFS on Mac
  • Terminal/shell familiarity

The steps:

  1. Install Terminal & SSH addon for your HA:
  2. Install MacFuse AND SSHFS (both!): https://osxfuse.github.io/
    • Unfortunately, it cannot be installed with homebrew anymore.
    • MacFuse uses a Kernel extension, so u will need to boot into Recovery and set the “Reduced Security” – I think the description is a bit misleading → I wouldn’t worry about it, the extension still needs to be (is being) signed by Apple.
  3. Mount your HA remote as a MacOS volume via SSHFS.
    • It is recommended not to mount at /Volumes/ → better to do it in your home dir. Therefore I mount it at ~/Volumes/homeassistant_ssh/ (notice the tilde!).
    • Not to repeat yourself, make a few shell scripts:
      ➜ cat sshfs_mount.sh 
      
      mkdir -p ~/Volumes/homeassistant_sshfs
      
      sshfs [email protected]:/ ~/Volumes/homeassistant_sshfs \
        -o reconnect \
        -o volname=homeassistant_sshfs
      
      ➜ cat sshfs_unmount.sh 
      
      diskutil unmount force ~/Volumes/homeassistant_sshfs
      
      ➜ cat sshfs_remount.sh 
      
      ./sshfs_unmount.sh
      ./sshfs_mount.sh
      
    • I actually just always call ./sshfs_remount.sh.
  4. Voila!

Footnotes:

  • I know… a bit complicated with all the SSH configurations and scripts… If you only want to mount for Finder → it will be easier with Samba. I personally switched to SSHFS because Pycharm was giving me issues.
  • It sometimes disconnects when Mac is put to sleep → just remount the volume.
  • Tested on: M1 Mac, Sonoma 14.3.1, MacFuse 4.6.1, SSHFS 2.5.0, HomeAssistant Core 2024.2.5, Terminal & SSH addon 9.10.0.
2 Likes

A tip for posteriority: if using the Advanced SSH & Web Terminal add-on, make sure the sftp option is enabled in the add-on configs.