首頁
» 如何
»
How to Mount a Remote SSHFS Directory Automatically at Boot in Debian
How to Mount a Remote SSHFS Directory Automatically at Boot in Debian
To mount a remote SSHFS directory automatically in Debian, configure noninteractive SSH authentication and add an SSHFS entry to /etc/fstab. With systemd, you can either connect during boot or activate an automount at boot and connect when the directory is first accessed. The second approach is useful when the remote server or network may be unavailable during startup.
This reference uses Debian 13 “trixie” documentation reviewed on October 9, 2026, including SSHFS 3.7.3 and systemd 257 documentation. The commands are configuration examples, not results from a tested deployment. Check your installed manuals if you use another release.
Choose when the SSHFS connection should start
Requirement
Configuration choice
Expected behavior
Make the directory available on demand after boot
Use x-systemd.automount
The first access triggers the remote mount.
Attempt the remote connection during boot
Omit x-systemd.automount
systemd starts the mount as part of startup.
Allow startup to continue if storage is unavailable
Use nofail
The mount is not a required boot dependency.
An application must wait for this storage
Add a dependency to that application’s service
The application starts only after the mount succeeds.
The main example uses an on-demand mount. The distinction matters: an active automount does not mean an SSHFS connection already exists. See Debian’s systemd automount manual for the relationship between the automount and its matching mount unit.
Before you start
The Debian client uses systemd and you have sudo access.
The remote account supports SFTP and can access the intended directory.
The client can reach the remote host, including any required VPN or jump host.
You have a way to verify the remote server’s SSH host-key fingerprint.
The local mount point is empty and is not a critical system directory.
Replace files@storage.example.net:/srv/data with your remote username, hostname, and directory. The hostname is a placeholder. The local mount point is /mnt/remote; the dedicated key is /root/.ssh/sshfs_boot.
This is an administrator-managed system mount. It runs locally as root but logs into the remote server as files, not remote root. The SSHFS project documentation generally recommends running ordinary interactive mounts as a regular user. A system boot mount requires deliberate credential and access management.
Install SSHFS on the Debian client. The remote system needs working SFTP service; it does not need an SSHFS installation just to serve files. If package installation fails, resolve the repository or connectivity issue before editing boot configuration.
Install the SSHFS client and OpenSSH tools on Debian.