SSHFS mounts a directory from a remote server over SSH, so it appears as a local folder. You can edit a website’s files on your VPS with your local editor, browse backups on a storage server, or let one server read files from another, all without setting up NFS or Samba, and with SSH’s encryption and key authentication.

Install

sudo apt install sshfs        # Debian/Ubuntu
sudo dnf install fuse-sshfs   # RHEL family (EPEL)
  • macOS: install macFUSE and SSHFS from the macFUSE site.
  • Windows: WinFsp plus SSHFS-Win, which mounts as a network drive (\\sshfs\user@host).

Your user needs SSH access to the server, ideally with a key. See SSH keys.

Mount and unmount

mkdir -p ~/mnt/web1
sshfs [email protected]:/var/www ~/mnt/web1
ls ~/mnt/web1

Unmount:

fusermount -u ~/mnt/web1        # Linux (fusermount3 on newer systems)
umount ~/mnt/web1               # macOS

With a non-standard SSH port or a specific key:

sshfs -p 2222 -o IdentityFile=~/.ssh/id_ed25519 [email protected]:/var/www ~/mnt/web1

Host aliases from ~/.ssh/config work too: sshfs web1:/var/www ~/mnt/web1. See SSH config file.

sshfs web1:/var/www ~/mnt/web1 \
  -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 \
  -o idmap=user,follow_symlinks
  • reconnect — re-establishes the connection after network drops (laptop sleep, Wi-Fi changes).
  • ServerAliveInterval — detects dead connections instead of hanging forever.
  • idmap=user — files owned by the remote user appear as owned by you locally.
  • follow_symlinks — resolve symlinks on the server side.

On macOS, -o volname=web1 gives the mount a nice name in Finder.

Permissions

Files keep their remote permissions and owners. You can only change what the remote SSH user may change. If the website files belong to www-data and you connect as deploy, editing fails unless deploy has write access, for example through a shared group. See Linux groups and ACLs.

By default, other local users (including root) can’t access your SSHFS mount. To allow them, add -o allow_other, after enabling user_allow_other in /etc/fuse.conf.

Mount automatically (server-to-server)

For a server that needs a remote directory permanently, for example to read backups, use fstab with a dedicated, passwordless key:

[email protected]:/srv/backups  /mnt/backups  fuse.sshfs  _netdev,noauto,x-systemd.automount,IdentityFile=/root/.ssh/backup_key,reconnect,ServerAliveInterval=15,allow_other,default_permissions  0  0
  • x-systemd.automount mounts on first access and doesn’t block boot if the remote server is down.
  • The first connection needs the remote host key in root’s known_hosts. Connect once manually with sudo ssh -i /root/.ssh/backup_key [email protected].

See fstab and mount.

Performance

SSHFS is convenient, not fast. Each file operation is a round trip over SSH.

  • Editing files and browsing: fine.
  • Many small files (git status in a large repository, npm install, find over thousands of files): slow. Run those commands on the server over SSH instead.
  • Large file copies: OK, but rsync or scp are faster and resumable. See rsync.

Options that help on slower links:

-o Compression=no          # on fast networks, compression only costs CPU
-o cache=yes,kernel_cache  # more caching (risk of stale data if others change files)

Latency matters most. Mounting a server in Tokyo from Europe feels sluggish. Mounting a server in the same data centre feels local.

Troubleshooting

Transport endpoint is not connected — the connection died and the mount is stale. Unmount with fusermount -u -z ~/mnt/web1 (lazy), then mount again. Use reconnect to avoid it.

fuse: device not found — the FUSE kernel module isn’t loaded (sudo modprobe fuse). Inside some containers FUSE isn’t available at all. On a KVM VPS it works normally.

read: Connection reset by peer right away — SSH authentication failed. Test plain ssh with the same user, host, port and key first.

Editor saves fail or create odd temp files — some editors use atomic save via rename. Try -o workaround=rename.

Alternatives

Need Better option
Shared storage between servers (production) NFS over a private network
One-way sync rsync (cron or systemd timer)
Two-way sync between devices Syncthing
Editing remote code VS Code Remote-SSH (runs tools on the server)

Quick reference

Task Command
Mount sshfs user@host:/path ~/mnt/dir
Unmount (Linux) fusermount -u ~/mnt/dir
Robust options -o reconnect,ServerAliveInterval=15,idmap=user
Custom port -p 2222
Stale mount fusermount -u -z ~/mnt/dir
Auto-mount fuse.sshfs line in fstab with x-systemd.automount

Related: scp and SSH tunnels.

  • SSH
  • Linux
  • Storage