Mounting remote file systems securely over SSH is a practical way to access files on another server as if they were stored locally. This guide explains how to install and use SSHFS to utilise SFTP (SSH File Transfer Protocol) to mount remote directories with SSH. And, make those mounts persistent.
Whether you’re backing up data, working across development environments, or managing files from multiple servers, SSHFS offers a secure, flexible solution.
Before mounting a remote directory, you need to install the SSHFS client. How you do this depends on your chosen distribution and its package manager below shows example commands for both debian and RHEL based systems using apt and dnf respectively.
For Debian-based systems (Ubuntu, Debian, Linux Mint):
sudo apt update
sudo apt install sshfs
For RHEL-based systems (Fedora, CentOS, AlmaLinux, Rocky Linux):
sudo dnf install sshfs
To access the remote filesystem locally, you need a directory to mount it to. You can start by creating one with mkdir.
mkdir /backup
Now, mount the remote folder using sshfs . The basic syntax is:
sshfs user@remote_host:/remote_path /local_mount_point
For example to mount the /home directory from a remote server at 192.168.1.10 to the local /backup folder you would use:
sshfs root@192.168.1.10:/home /backup
You’ll be prompted to enter the SSH password for the user. After authentication, the remote directory will be accessible under /backup.
Repeated password prompts can become tedious. To simplify access:
n
This allows secure, password less connections via SSH.
1. To ensure the remote file system mounts automatically at boot, add an entry to the /etc/fstab file.
sudo nano /etc/fstab
2. Now add this line, replacing user, host, and paths as needed:
sshfs#root@192.168.1.10:/home /backup fuse.sshfs defaults 0 0
3. Save the file and reboot the system:
sudo reboot
After reboot, the remote directory should be automatically mounted.