Mounting a remote directory over SSH lets local editors, shell tools, and file managers work with files that still live on another host. SSHFS fits cases where an operator already has SSH access and needs a temporary filesystem view instead of repeated copy commands.
SSHFS is a FUSE client that talks to the server's SFTP subsystem through OpenSSH. The mount command uses the same account, host key trust, private keys, and connection options as a normal ssh user@host.example.net login, so the server usually does not need a separate file-sharing service.
Run SSHFS as the regular local user that will read or write the mounted path, and mount onto an empty directory owned by that user. Remote ownership and permissions still decide what can be changed, and reconnect options can restore the session after a dropped link, but files that were open during the interruption may need to be reopened.
Related: How to copy a file over SSH
Related: How to configure passwordless SSH login
Steps to mount a remote filesystem with SSHFS:
- Confirm that the remote account can list the target directory over SSH.
$ ssh user@host.example.net 'ls /home/user/remotefolder' readme.txt
SSHFS uses the same remote account permissions as SSH and SFTP, so a directory that cannot be listed here will fail before the mount appears.
- Create an empty local mount point owned by the local user.
$ mkdir -p /home/user/remote
Files already present under /home/user/remote stay hidden while the remote filesystem is mounted there.
- Mount the remote directory with SSHFS.
$ sshfs -o reconnect -o ServerAliveInterval=15 user@host.example.net:/home/user/remotefolder /home/user/remote
If the username is omitted, SSHFS uses the current local username. If the remote directory is omitted, SSHFS mounts the remote home directory.
- Check that the mount points at the expected remote path.
$ findmnt /home/user/remote TARGET SOURCE FSTYPE OPTIONS /home/user/remote user@host.example.net:/home/user/remotefolder fuse.sshfs rw,nosuid,nodev,relatime,user_id=1000,group_id=1000
The FSTYPE value commonly appears as fuse.sshfs even though the client command is sshfs.
- List the mounted directory through the local path.
$ ls /home/user/remote readme.txt
- Create a test file through the mount when write access is required.
$ touch /home/user/remote/file.txt
Skip this write test for read-only remote paths.
- Confirm that the test file exists on the remote host.
$ ssh user@host.example.net 'ls -l /home/user/remotefolder' total 4 -rw-r--r-- 1 user user 0 Jun 13 01:21 file.txt -rw-r--r-- 1 user user 19 Jun 13 01:21 readme.txt
A write failure through the mount usually points to remote directory ownership or permissions, not to the local mount point.
- Unmount the SSHFS filesystem when the local view is no longer needed.
$ fusermount3 -u /home/user/remote
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.