How to mount remote file systems over SSH

May 6, 2024 / How-to Guide

This article explains how to mount remote file systems over SSH. It covers installing the SSHFS client on Linux and the process of mounting remote directories over SSH.

SSHFS (SSH Filesystem) is a filesystem client leveraging FUSE to mount remote directories via SSH connections. It utilises the SFTP protocol, a default subsystem of SSH commonly enabled on SSH servers.

  1. Install SSHFS-
    SSHFS packages are available for all major operating systems.

    1. For Ubuntu / Debian-
      apt update
      apt install sshfs
    2. For RHEL & Centos & Fedora & AlmaLinux-
      dnf install sshfs
  2. Mounting a Remote File System-
    1. In order to mount the remote file system, you must create a local directory. In this instance, it will be a folder named /backup-
      mkdir /backup
    2. To mount remote directory-
       sshfs user@host:/remote_directory  /local_directory
    3. In my scenario, I aim to mount the folder /home from the remote server to my local directory /backup-
      sshfs [email protected]:/home   /backup
      You will receive a prompt to input the user password. To avoid entering the password repeatedly, it is advisable to generate SSH keys.
    4. To establish a persistent mount point, we will edit the /etc/fstab file on the server to automatically mount the file system upon each system boot-
      sshfs [email protected]:/home   /backup    fuse.sshfs      defaults 0 0
    5. Save the modifications made to /etc/fstab and reboot the system.
  3. Unmounting a remote file system-
    To dismount a remote file system, employ either the umount or the fusermount command, followed by the directory where it has been mounted (mount point) –
    fusermount -u /backup
    umount /backup

This method allows you to mount remote file systems over SSH. We hope you found our article helpful. If you encounter any difficulties, please do not hesitate to reach out to our support specialists for assistance.


Dominos Search