You need to open some files on a server, but your editor and file manager are running on the local workstation. SSHFS mounts the remote directory into the Linux file tree by reusing your SSH connection. It is suitable for file retrieval, troubleshooting, or occasional administrative intervention.
Test SSH, the mount point, and the account before mounting anything. A network interruption can leave access blocked. For a directory shared permanently between multiple machines or services, use NFS or storage designed for this purpose.
Prepare the client and mount point
Install sshfs on the client machine. It relies on FUSE and the SFTP subsystem of OpenSSH. The server must accept SSH and offer SFTP. No additional sharing daemon is required when SFTP is already available.
sudo apt install sshfs # Debian, Ubuntu
sudo dnf install sshfs # Fedora (RHEL depending on the enabled repositories)
sudo pacman -S sshfs # Arch Linux
Create an empty folder that you own. Avoid /mnt if you do not have rights. Do not run SSHFS with sudo to bypass this issue.
mkdir -p ~/mnt/server-docs
stat -c '%U %G %A %n' ~/mnt/server-docs
ssh -o BatchMode=yes [email protected] true
The last command should finish without asking for a password. If your key is protected by a passphrase, load it into an SSH agent rather than removing this protection. If the test fails, fix the host, port, or key before mounting. SSHFS assumes a functional SSH connection. An SSH config file avoids repeating options when managing multiple servers.
Mount the remote directory
The command follows this pattern: user@host:remote-path local-mount-point. The remote path is interpreted by the server. Here, /srv/documents is mounted at ~/mnt/server-docs.
sshfs [email protected]:/srv/documents ~/mnt/server-docs
-o idmap=user,ServerAliveInterval=15,ServerAliveCountMax=3,reconnect
idmap=user presents the remote files as belonging to your local user. This option does not grant you any additional rights on the server. Remove it and run ls -ln if you need to check the UID and GID returned by SSHFS. Do not add allow_other by reflex: this option opens the mount to other local accounts and requires proper FUSE configuration.
ServerAliveInterval=15 sends keep-alive requests every 15 seconds. With ServerAliveCountMax=3, the client drops a session that does not respond after three failures, and then reconnect attempts to restore the mount. These options do not make an interrupted write atomic. After a disconnection, close and reopen the file before resuming editing.
Check the mount before making any changes
Before drag-and-drop or modification, check the source, the file system type, and an expected file. findmnt allows you to distinguish the SSHFS mount from the local folder that usually covers it.
findmnt -T ~/mnt/server-docs -o TARGET,SOURCE,FSTYPE
ls -ln ~/mnt/server-docs
sed -n '1,10p' ~/mnt/server-docs/README.txt
Make sure that FSTYPE indicates fuse.sshfs and that SOURCE designates the expected server. Otherwise, you are working in the local folder or on another mount. If the permissions are surprising, check the SSH account and the permissions of /srv/documents on the server.
SSHFS avoids installing a network share to retrieve a file. For a directory used permanently by multiple Linux machines, also consult our guide on mounting an NFS share. NFS is better suited for this use if you control the network and the machines.
Unmount after the intervention
Close the terminals located in the mounted directory and the applications that opened a file there. Then unmount the local point with FUSE 3.
cd ~
fusermount3 -u ~/mnt/server-docs
findmnt -T ~/mnt/server-docs -o TARGET,SOURCE,FSTYPE
After unmounting, the output should no longer indicate fuse.sshfs. If it signals a resource is busy, first identify the concerned processes:
fuser -vm ~/mnt/server-docs
A network loss can leave SSHFS blocked. Stop its process only after verifying that no copy or write operation is underway. Keep a local copy of important files and restart the transfer after checking.
Do not automate a fragile mount
Do not place this mount in /etc/fstab on first use. Test several manual mounts and unmounts, including after sleep or VPN disconnection. A service that starts before the network or reads this directory may be slowed down or blocked.
A demand-mounted connection with systemd may suit a mobile workstation after these tests. Use a dedicated key, limit its rights on the server side, and choose a distinct mount point. The guide fstab under Linux helps choose a permanent mount. SSHFS should not be the only access to production data.
The documentation sshfs(1) details the FUSE options, identifier mapping, and limits after a network interruption.