Objectives
Use SSHFS to Mount Remote File Systems Over SSH
Prerequisites
- Server with Ubuntu/Debian installed.
Steps
Step 1: Installing SSHFS
Firstly, install the SSHFS software through apt-get.
apt-get install sshfs
Step 2: Create and Mount Remote File System
On your Linux machine, create a local directory as a destination for the mounted folder.
mkdir /mnt/share_drive
Now Use sshfs to mount the home directory of the remote system’s user to the newly-created directory.
sshfs -o allow_other,default_permissions [email protected]:/ /mnt/share_drive
The example uses IP 192.168.1.1 as the targeted host, do ensure you have specify the correct IP according to your setup.
Step 3: Unmount the Remote File System
If the mounted folder is no longer needed, you can simply unmount the folder via: –umount /mnt/share_drive
Step 4: Creating Persistent / Permanent Mounts
Persistent mounts are essential in order to retain the server’s mounted directories even through reboots. This can be easily done by updating the fstab file.
First, open the fstab file via nano file editor.
nano /etc/fstab
Move to the bottom of the file and add the following entry.
sshfs#[email protected]:/ /mnt/share_drive
The example uses IP 192.168.1.1 as the targeted host, do ensure you have specify the correct IP according to your setup.
Now reboot the system either through reboot OR init 6.
Your system should still retain the mounted directories even after rebooting.