Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SSHFS: Mount Remote Linux Files Over SSH

· 7 min read · Home Tech

In this article
  1. What SSHFS Is and Why It Exists
  2. How SSHFS Compares to Other Remote File Methods
  3. Installing SSHFS on Your Local Machine
  4. Mounting a Remote Directory: Step-by-Step
  5. Common Problems and How to Fix Them
  6. Security and Safety Considerations
  7. Alternatives and When to Choose Them
  8. Frequently Asked Questions

Yes, you can browse remote Linux PC files with SSHFS, a filesystem client that mounts a remote directory over SSH into your local file tree. It works without any special server software beyond an SSH server, and it gives you a seamless way to read and write files on another machine as if they were on your own disk.

What SSHFS Is and Why It Exists

SSHFS (SSH Filesystem) is a tool built on FUSE (Filesystem in Userspace) that lets you mount a remote directory using the SSH File Transfer Protocol (SFTP). SFTP is a subsystem of SSH, so if you can already ssh into a machine, you can usually mount its files with SSHFS without installing anything on the remote side. The project is part of the libfuse ecosystem and has been around since the early 2000s, maintained by the same community that develops FUSE for Linux.

The core idea is simple: your local kernel forwards file operations (open, read, write, list) to a user-space daemon (sshfs), which translates them into SFTP requests over an encrypted SSH connection. From the application's perspective, the mounted directory is just a normal local folder, so any program that can read local files can read remote ones.

How SSHFS Compares to Other Remote File Methods

Before choosing SSHFS, it helps to know what else exists. The main alternatives are NFS (Network File System), SMB/CIFS (Windows-style sharing), and plain SFTP clients like FileZilla or sftp on the command line.

  • NFS: Fast and native on Linux, but requires root configuration on the server, opens extra ports, and has weaker encryption unless you add Kerberos. It's best for trusted local networks.
  • SMB/CIFS: Works well with Windows and macOS, but setup on Linux servers can be fiddly, and performance over high-latency links is often worse than SSHFS.
  • SFTP clients: Good for one-off transfers, but you can't run local tools like grep, rsync, or a text editor directly on remote files without manually downloading and uploading.
  • SSHFS: Gives you a true mounted filesystem with no server-side configuration, works over any network where SSH works (including the internet), and inherits SSH's strong encryption and authentication.

The tradeoff is performance: SSHFS is generally slower than NFS on a fast LAN because of encryption overhead and SFTP protocol round-trips. On a gigabit network, you might see 50-100 MB/s instead of 300+ MB/s with NFS. For most browsing and editing tasks, that's acceptable.

Installing SSHFS on Your Local Machine

SSHFS is a client-side tool; the remote machine only needs an SSH server (usually OpenSSH). On your local Linux system, install it with your package manager:

  • Debian/Ubuntu: sudo apt install sshfs
  • Fedora/RHEL: sudo dnf install fuse-sshfs
  • Arch: sudo pacman -S sshfs

On Windows, you can use WinFsp and SSHFS-Win, which provides a similar experience. On macOS, SSHFS is available via Homebrew (brew install sshfs) but note that macOS's FUSE support has changed over recent versions, so check the project's current status.

Mounting a Remote Directory: Step-by-Step

Once installed, the basic command is:

sshfs user@remote-host:/path/to/dir /local/mountpoint

For example, to mount /home/alice/projects from a server at 192.168.1.50 onto your local ~/remote-projects:

  1. Create the mountpoint: mkdir -p ~/remote-projects
  2. Run: sshfs alice@192.168.1.50:/home/alice/projects ~/remote-projects
  3. Enter your password (or use an SSH key).
  4. Browse ~/remote-projects with your file manager or terminal.

To unmount, use fusermount -u ~/remote-projects (or umount on some systems). If the mount is busy, add -z to force it.

For convenience, you can add options like -o reconnect to auto-reconnect if the network drops, -o ServerAliveInterval=15 to keep the connection alive, and -o idmap=user to map remote user IDs to your local user, avoiding permission errors when the remote UID differs.

Common Problems and How to Fix Them

Most SSHFS issues fall into a few categories:

  • Permission denied: The remote user may not have read access to the path. Check with ls -ld /path on the server. Also, if your local UID doesn't match the remote UID, files may appear owned by nobody; use -o idmap=user to map your local user to the remote one.
  • Connection drops: Add -o reconnect and -o ServerAliveInterval=15 to keep the session alive and auto-reconnect.
  • Slow performance: Try -o compression=yes for text-heavy workloads, or -o Ciphers=aes128-ctr if your CPU is old. For large file transfers, consider rsync over SSH instead, which is faster because it doesn't go through FUSE.
  • Mount hangs on unmount: If a process is using the mount, unmount will fail. Use lsof +f -- /mountpoint to find and close the process, then unmount again.
  • SSH key passphrase prompts: Use ssh-add to add your key to an agent so SSHFS doesn't prompt repeatedly.

A common misconception is that SSHFS requires root on the remote machine. It doesn't—you can mount any directory your SSH user can read/write. However, if you need to mount a system directory like /etc, you'll need a user with appropriate permissions.

Security and Safety Considerations

SSHFS inherits SSH's security, so your data is encrypted in transit and authentication is handled by SSH keys or passwords. That's a major advantage over NFS on untrusted networks. However, there are caveats:

  • Don't expose SSH to the internet without key-based auth and ideally fail2ban or similar. SSHFS on a public server is only as secure as your SSH configuration.
  • Be careful with root mounts: If you mount as root, a compromised local process could read or write remote files with root privileges. Prefer a non-root user.
  • Unmount before disconnecting: If you just kill the network, the mount may become stale. Use -o reconnect to handle transient drops, but for intentional disconnects, unmount cleanly.
  • Permissions are enforced by the remote server: SSHFS doesn't add its own permission layer; it relies on the remote filesystem's permissions. So if the remote user can delete a file, so can you through the mount.

For sensitive data, consider using SSHFS over a VPN or SSH tunnel to avoid exposing the SSH port directly. Also, note that SSHFS is not a backup tool—if you accidentally delete a file on the remote, it's gone (unless you have other backups).

Alternatives and When to Choose Them

SSHFS is ideal for interactive browsing, editing, and small-to-medium file operations. But for heavy workloads, consider:

  • rsync: For one-time or scheduled bulk transfers, rsync over SSH is faster and more reliable than SSHFS because it doesn't have FUSE overhead.
  • NFS: If both machines are on a trusted LAN and you need high throughput, NFS with Kerberos can be faster and more scalable.
  • Syncthing: For continuous two-way sync without mounting, Syncthing is a modern alternative that works well across platforms.
  • Nextcloud or Seafile: For a full cloud-like experience with web access, versioning, and sharing, these are better than SSHFS.

If you only need to occasionally copy a few files, a plain scp or sftp session might be simpler and faster to set up. SSHFS shines when you want to use local tools (editors, IDEs, file managers) on remote files without manual sync.

Frequently Asked Questions

Does SSHFS work on Windows or macOS?

Yes. On Windows, SSHFS-Win (with WinFsp) provides a similar mount experience. On macOS, you can install sshfs via Homebrew, but note that macOS's FUSE support has been inconsistent; check the current project status before relying on it.

Can I mount a remote directory without root on the remote machine?

Yes, SSHFS requires no root on the remote side. You just need an SSH account with read/write access to the directory you want to mount. This is one of its main advantages over NFS.

Why is SSHFS slow for large file transfers?

SSHFS goes through FUSE and SFTP, which adds overhead compared to a raw TCP transfer. For large files, use rsync over SSH instead; it's optimized for bulk data and can be many times faster.

How do I make SSHFS auto-mount at boot?

You can add an entry to /etc/fstab like user@host:/path /mnt/point fuse.sshfs defaults,_netdev,users,idmap=user,allow_other 0 0. You'll need to use an SSH key without a passphrase (or an agent) for non-interactive mounting. Alternatively, use systemd mount units for more control.

Is SSHFS safe to use over the internet?

Yes, because it uses SSH encryption. However, you should secure your SSH server with key-based authentication and consider limiting access via firewall or fail2ban. Also, be aware that the remote server sees all your file operations, so only use it on machines you trust.

Can I mount a remote directory and have it appear in my file manager's sidebar?

Yes, if you mount it at a standard location like ~/mnt/remote, most file managers (Nautilus, Dolphin, Thunar) will show it as a mounted volume. Some file managers also have built-in SSH support (e.g., Nautilus's sftp:// URLs) which is simpler for occasional use.