Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Filesystem»How to Mount Remote File System over SSH in Linux

    How to Mount Remote File System over SSH in Linux

    RahulBy RahulMay 9, 20143 Mins ReadUpdated:July 10, 2021

    SSHFS is a filesystem based on the SSH File Transfer Protocol (SFTP). On remote side we just need to install SSH server, Since most of SSH servers already support this, there are nothing to do on remote server except installing SSH server. On client side we need to install fuse sshfs packages to mount remote filesystem. Newer version of SSHFS uses FUSE. The FUSE version of SSHFS is rewrite by Miklos Szeredi.

    Features of SSHFS:

      • Based on FUSE (Best userspace filesystem framework for linux)
      • Multithreading: more than one request can be on it’s way to the server
      • Allowing large reads (max 64k)
      • Caching directory contents

    Step 1 – Install FUSE-SSHFS

    For CentOS/RHEL users, Fuse SSHFS is available under epel repository, So make sure you have install epel repository in your system. Now execute following command to install it

    On CentOS/RHEL:

    # yum install fuse-sshfs
    

    On Ubuntu & Dabian:

    $ sudo apt-get update
    $ sudo apt-get install sshfs
    

    Step 2 – Mount Remote Directory

    Let’s mount the remote server directory using sshfs. Make sure the remote system has a running ssh server with proper ssh connectivity from your system.

    First, create a mount point

    # mkdir /mntssh
    

    Lets mount the remote directory. For this example we are mounting /home/remoteuser directory from 192.168.1.12 (remote.example.com) system to our local system.

    # sshfs [email protected]:/home/remoteuser /opt/mntssh
    

    [Sample output]

    The authenticity of host 'remote.example.com (192.168.1.12)' can't be established.
    RSA key fingerprint is 77:85:9e:ff:de:2a:ef:49:68:09:9b:dc:f0:f3:09:07.
    Are you sure you want to continue connecting (yes/no)? yes
    [email protected]'s password:
    

    Step 3 – Verify Mount

    After mounting the remote filesystem on the local mount point, verify it by running the mount command.

    # mount
    
    /dev/mapper/vg_svr1-lv_root on / type ext4 (rw)
    proc on /proc type proc (rw)
    sysfs on /sys type sysfs (rw)
    devpts on /dev/pts type devpts (rw,gid=5,mode=620)
    tmpfs on /dev/shm type tmpfs (rw)
    /dev/sda1 on /boot type ext4 (rw)
    [email protected]:/home/remoteuser on /mntssh type fuse.sshfs (rw,nosuid,nodev)
    

    Also, navigate to your mount point, you will see files therefrom remote system

    # cd /mntssh
    # ls
    

    Step 4 – Mount Directory on System Boot

    If you want to mount remote filesystem automatically each time when your system reboots, Add following entry to /etc/fstab file. Make sure you have have key based ssh setup between remote and local system.

    [email protected]:/home/remoteuser /mntssh fuse.sshfs defaults 0 0
    

    Step 5 – Unmount Directory

    If your work is over and you don’t need anymore the mounted directory, Simply unmount it using the following command.

    # umount /mntssh
    

    Also remove entry from /etc/fstab file

    filesystem mount network-drive remote SSH sshfs
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Setup VNC Server (Linux Remote Desktop Access) on CentOS/RHEL and Fedora
    Next Article How to Use If, else and elif statements in Shell Scripting

    Related Posts

    (Resolved) userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms

    Updated:May 10, 20221 Min Read

    Adding a New SSH Key in GitHub

    Updated:April 1, 20223 Mins Read

    How to Create SFTP Only User in Debian 11

    Updated:September 26, 20214 Mins Read

    How to Disable Strict Host Key Checking in SSH

    Updated:September 25, 20212 Mins Read

    How To Set Up SSH Keys in Linux

    5 Mins Read

    How To Set Up SSH Tunneling

    5 Mins Read

    4 Comments

    1. Jeff Noble on March 9, 2021 3:47 pm

      This did not work on RHEL 8.
      sudo yum install fuse-sshfs
      Updating Subscription Management repositories.
      Unable to read consumer identity

      This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

      Red Hat Enterprise Linux 8 for x86_64 – AppStre 41 MB/s | 26 MB 00:00
      Red Hat Enterprise Linux 8 for x86_64 – BaseOS 44 MB/s | 28 MB 00:00
      No match for argument: fuse-sshfs
      Error: Unable to find a match: fuse-sshfs

      Reply
    2. Milad on July 8, 2019 8:34 am

      We want to monitor SSHFS mount point with SNMP in Ubuntu but it doesn’t show any SSHFS mount point. Maybe because it is encrypted. How we can solve this?

      Note: we don’t have problem with NFS.

      snmpwalk -v 2c -c public localhost UCD-SNMP-MIB::dskTable
      or

      snmpwalk -v 2c -c public localhost HOST-RESOURCES-MIB::hrFSRemoteMountPoint
      When we request with above commands there is no mountpoint in result but we have MountPoint when we do df.

      df

      Reply
    3. Mohammad on May 2, 2017 3:40 pm

      HI i did all of the things and it has an error ” connection peer rest”
      what should I do ?

      Reply
    4. Randy Douglas on May 13, 2014 2:40 pm

      Nice article… Something new for me…

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.