Skip to content

Instantly share code, notes, and snippets.

@mikaeldui
Last active April 22, 2025 21:53
Show Gist options
  • Save mikaeldui/53d78b2d6ddad9dd80458579af7d9f07 to your computer and use it in GitHub Desktop.
Save mikaeldui/53d78b2d6ddad9dd80458579af7d9f07 to your computer and use it in GitHub Desktop.
Systemd .mount for SSHFS

Mounting SSHFS (SFTP) using systemd

Why use fstab when there's systemd?

# /etc/systemd/system/media-server1.mount
[Unit]
Description=Mount unit for Server1

[Mount]
What[email protected]:/
# Where= must be the same as the file name! / is replaced by - in the file name.
Where=/media/server1
# You might have to install fuse first.
Type=fuse.sshfs
# Seems these are just fstab options.
Options=IdentityFile=/home/USERNAME/.ssh/id_ed25519,noauto,x-systemd.automount,_netdev,allow_other

[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment