sshfs and rclone mount: Mounting Remote Storage as a Local Folder

sshfs and rclone mount: Mounting Remote Storage as a Local Folder

Sometimes you want remote files to just be a folder: open them in your editor, point a media player at them, or run grep across them, without copying anything first. Two tools do this well on Linux:

  • sshfs mounts any directory you can reach over SSH
  • rclone mount mounts cloud and object storage: S3, Backblaze B2, Google Drive, OneDrive, WebDAV, and dozens more

Both are built on FUSE (Filesystem in Userspace), which lets an ordinary program implement a filesystem without kernel code.

sshfs

If you can ssh to a machine, you can mount it. sshfs speaks SFTP, which every OpenSSH server already provides, so there is nothing to install on the server.

sudo apt install sshfs      # Debian / Ubuntu
sudo dnf install fuse-sshfs # Fedora
sudo pacman -S sshfs        # Arch

mkdir -p ~/mnt/server
sshfs alice@server:/srv/data ~/mnt/server
ls ~/mnt/server

It uses your normal SSH setup: keys, ~/.ssh/config host aliases, jump hosts, and agents all work. Our SSH keys guide and the SSH config builder help if those are not set up yet.

# with a host alias from ~/.ssh/config
sshfs myserver:/srv/data ~/mnt/server

Options worth using

sshfs myserver:/srv/data ~/mnt/server \
  -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 \
  -o idmap=user \
  -o compression=no
  • reconnect and ServerAlive*: without these, a dropped connection leaves the mount hanging indefinitely, and anything that touches it, including your shell’s tab completion, freezes
  • idmap=user: maps the remote user’s files to your local user, so ownership looks sensible
  • compression=no: on a fast network, compression costs more CPU than it saves. Turn it on for slow links

Unmounting

fusermount3 -u ~/mnt/server
# stuck after a network failure:
fusermount3 -uz ~/mnt/server

Mounting at boot

For a persistent mount, an /etc/fstab entry with systemd automount is the robust way. The mount only connects when something accesses it, and a timeout stops boot from hanging if the server is down:

alice@server:/srv/data  /mnt/server  fuse.sshfs  noauto,x-systemd.automount,x-systemd.mount-timeout=15,_netdev,reconnect,ServerAliveInterval=15,IdentityFile=/home/alice/.ssh/id_ed25519,allow_other,idmap=user  0  0

Because the mount is performed by root at boot, it needs an explicit IdentityFile, and allow_other (which requires user_allow_other in /etc/fuse.conf) lets your normal user access it. Our fstab guide and fstab line builder explain each field.

rclone mount

rclone is a command-line tool for cloud storage, often described as rsync for the cloud. It supports over 70 storage providers. Its mount command exposes any of them as a local directory.

Configure a remote

sudo apt install rclone     # or: sudo dnf install rclone
rclone config

rclone config walks you through adding a remote: pick the provider, enter keys or complete an OAuth login in your browser, and give it a name like b2 or gdrive. Check it works:

rclone lsd b2:
rclone ls b2:my-bucket | head

Mount it

mkdir -p ~/mnt/b2
rclone mount b2:my-bucket ~/mnt/b2 --vfs-cache-mode full --daemon

Why the VFS cache matters

Object storage like S3 is not a filesystem. You cannot modify part of an object in place, rename is really copy plus delete, and there are no real directories. Many applications assume those things work.

rclone’s VFS cache bridges the gap:

--vfs-cache-modeBehaviourUse for
offReads and writes stream directly. Many apps fail on writesRead-only browsing
minimalFiles opened for read and write are cachedLight use
writesFiles are written locally first, then uploadedMost read-write use
fullReads and writes both cached on local diskMedia servers, editors, anything that seeks

full is the safe default for general use. Pair it with --vfs-cache-max-size 20G to cap local disk usage.

Running it as a service

A systemd user service keeps the mount up:

# ~/.config/systemd/user/rclone-b2.service
[Unit]
Description=rclone mount b2
After=network-online.target

[Service]
Type=notify
ExecStart=/usr/bin/rclone mount b2:my-bucket %h/mnt/b2 --vfs-cache-mode full --vfs-cache-max-size 20G
ExecStop=/bin/fusermount3 -u %h/mnt/b2
Restart=on-failure

[Install]
WantedBy=default.target
systemctl --user daemon-reload
systemctl --user enable --now rclone-b2.service

Our systemd service files guide covers the directives, and the systemd unit builder can generate one.

Mount or sync?

A mount is convenient, but it is a poor fit for some jobs:

  • Backups and bulk transfers: use rclone sync or rclone copy, or rsync for SSH targets. They are faster, resumable, can verify checksums, and do not depend on a FUSE layer. See rsync explained and restic vs borg
  • Databases and anything with file locking: never put a database on sshfs or rclone. Locking semantics are not reliable over either
  • Many small files: every file operation is a network round trip, so tools like git status on a mounted repository are painfully slow

A mount is the right tool when an application needs to browse or open remote files as if local: a media server reading a cloud library, occasional editing of files on a server, or a file manager view of a bucket.

sshfs vs NFS and Samba

On a trusted local network, NFS or Samba will be faster, because they run in the kernel (NFS) or are heavily optimised, and do not encrypt by default. sshfs is the answer when you want zero server setup and encryption across untrusted networks: if SSH works, the mount works.

Frequently Asked Questions

What is sshfs?

sshfs is a FUSE filesystem that mounts a directory from a remote machine over SSH using the SFTP protocol. Anything you can reach with ssh can be mounted as a local folder, with no extra server software, using the same keys and permissions as your SSH login.

What is rclone mount?

rclone mount uses FUSE to present any storage rclone supports, including S3, Backblaze B2, Google Drive, OneDrive, WebDAV and SFTP, as a local directory. Its VFS cache layer makes applications that expect normal file behaviour work on top of object storage.

How do I unmount an sshfs or rclone mount?

Run fusermount3 -u followed by the mount point, or fusermount -u on older systems. If the connection has died and the mount is stuck, add -z for a lazy unmount, which detaches it immediately and cleans up once nothing is using it.

Why is my sshfs mount frozen after the network dropped?

By default sshfs waits indefinitely for the server. Mount with -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 so it detects a dead connection and reconnects. For mounts that must not hang the system, use a systemd automount with a timeout.

Should I use rclone mount or rclone sync?

Use sync or copy for backups and bulk transfers, because they are faster, resumable and predictable. Use mount when an application needs to browse or open remote files as if they were local, such as a media server reading a library stored in the cloud.

Is sshfs faster than NFS or Samba?

Usually not. sshfs encrypts everything and runs in userspace, so on a trusted local network NFS or Samba give better throughput. sshfs wins on convenience: it needs nothing but an SSH login, works across the internet securely, and requires no server configuration.