Mount SFTP folders in network storage, as CoreDesktop does

configure storage now finds machines that announce SFTP as well as SMB
servers, and takes sftp://[user@]host[:port][/path] addresses. Folders
are mounted with SSHFS on macFUSE, as you, with your SSH keys
(Bitwarden's SSH agent while it runs one), and never ask for a
password. storage-mount mounts them again at login and when the
network changes, as it does SMB shares; each line of the list now
records its mount point.

macFUSE and SSHFS are offered for download, checked against their
Team ID (3T5GSNBU6W, read from the packages' signatures). On macOS 26
and later macFUSE mounts through FSKit, whose extension you turn on
once in System Settings. Earlier macOS needs its kernel extension,
which this uses if it's running but doesn't set up.

smoketest: 85-sftp installs both and mounts a folder from the VM
itself over SSH, if macFUSE's extension can be turned on there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 08:55:55 -07:00
co-authored by Claude Opus 5.5
parent 08e6b2ee4f
commit 8e2a886215
7 changed files with 436 additions and 60 deletions
+83
View File
@@ -0,0 +1,83 @@
# shellcheck shell=bash
DESCRIPTION="SFTP folders: macFUSE and SSHFS install, and the VM mounts a folder from itself over SSH"
TIER=quick
source "$CONNECTOR/configure.d/60-storage.sh"
SOURCE_DIR="$HOME/sftp-source"
URL="sftp://$USER@localhost$SOURCE_DIR"
job_loaded() {
launchctl print "gui/$(id -u)/$LABEL" > /dev/null 2>&1
}
# The id of macFUSE's file system extension, as pluginkit lists it
fsmodule_id() {
pluginkit -m -A -D -p com.apple.fskit.fsmodule 2> /dev/null | grep -i macfuse | head -n 1 \
| sed -E 's/^[-+=!? ]*//; s/[[:space:]]*\(.*$//; s/[[:space:]].*$//'
}
point_of() {
awk -F'|' -v url="$URL" '$1 == url { print $2 }' "$STORAGE_CONF"
}
reads_through_mount() {
[ "$(cat "$(point_of)/hello.txt")" = "hello over sftp" ]
}
writes_through_mount() {
echo written > "$(point_of)/from-mount.txt" && [ "$(cat "$SOURCE_DIR/from-mount.txt")" = written ]
}
remounts() {
local point
point="$(point_of)"
sftp_unmount "$point" || return 1
sftp_mounted "$point" && return 1
bash "$STORAGE_MOUNT"
sleep 3
sftp_mounted "$point"
}
scenario() {
local backend id
check "fuse_backend picks one" fuse_backend
backend="$(fuse_backend)"
[ -n "$backend" ] || { skip "This macOS can't mount over SFTP without macFUSE's kernel extension"; return; }
check_eq "it's FSKit on macOS 26 and later" fskit "$backend"
step "Installing macFUSE and SSHFS (Team IDs checked)"
check "app_install macfuse" app_install macfuse
check "app_install sshfs" app_install sshfs
check "sshfs runs" "$SSHFS" --version
step "macFUSE's file system extension"
id="$(fsmodule_id)"
if [ -z "$id" ]; then
skip "pluginkit doesn't list macFUSE's extension, so fskit_enabled can't tell whether it's on"
else
check "pluginkit lists it ($id)" true
fskit_enabled || pluginkit -e use -i "$id" 2> /dev/null
sleep 2
fi
if ! fskit_ready; then
skip "Turning macFUSE's extension on needs a click in System Settings: check mounting by hand"
return
fi
step "A folder from this Mac, over SSH"
mkdir -p "$HOME/.ssh" "$SOURCE_DIR"
echo "hello over sftp" > "$SOURCE_DIR/hello.txt"
[ -f "$HOME/.ssh/id_ed25519" ] || ssh-keygen -q -t ed25519 -N '' -f "$HOME/.ssh/id_ed25519"
cat "$HOME/.ssh/id_ed25519.pub" >> "$HOME/.ssh/authorized_keys"
ssh-keyscan -H localhost >> "$HOME/.ssh/known_hosts" 2> /dev/null
mkdir -p "$CONF_DIR"
: > "$STORAGE_CONF"
check "sftp_key_works" sftp_key_works "$URL"
check "add_sftp mounts it and adds it to the list" add_sftp "$URL"
check "launchd has the job" job_loaded
check "a file reads through the mount" reads_through_mount
check "a file written through the mount lands on the server" writes_through_mount
check "storage-mount mounts it again after it's unmounted" remounts
check "remove_share" remove_share "$URL" "$(point_of)"
check_not "it's no longer in the list" grep -qF "$URL" "$STORAGE_CONF"
}