This tutorial will show you how to install the SSHFS client on Linux and how to mount a remote file systems over SSH.
SSHFS (SSH Filesystem) is a filesystem client based on FUSE for mounting remote directories over an SSH connection. SSHFS is using the SFTP protocol, which is a subsystem of SSH, and it is enabled by default on most SSH servers.
Install SSHFS
SSHFS packages are available for all major operating systems.
Ubuntu / Debian
apt update apt install sshfs
RHEL & Centos & Fedora & AlmaLinux
dnf install sshfs
Mounting a Remote File System
You need to create a local directory in which to mount the remote file system. In my case, it will be a folder /backup
mkdir /backup
To mount remote directory.
sshfs [email protected]:/remote_directory /local_directory
In my case, I want to mount a folder /home from remote server 192.168.1.10 to my local folder /backup
sshfs [email protected]:/home /backup
You will be prompted to enter the user password. To avoid typing the password each time, you should generate SSH keys. Check the manual here – How to set up SSH keys
In order to set up a permanent mount point, we will need to edit the /etc/fstab file on the server to automatically mount the file system each time the system is booted.
sshfs [email protected]:/home /backup fuse.sshfs defaults 0 0
Save the changes to /etc/fstab and reboot.
Unmounting a remote file system
To unmount a remote file system use umount or fusermount command followed by the directory where it has been mounted (mount point):
fusermount -u /backup umount /backup