How to mount a Remote File System Using SSHfs on Linux

Source: Internet
Author: User

How to mount a Remote File System Using SSHfs on Linux

Have you ever thought about using a secure shell to mount a remote file system to a local device? If so, SSHfs may be what you need. It uses SSH and Fuse (LCTT: Filesystem in Userspace, a user-mode file system, which is a module used in Linux to mount certain network spaces, such as SSH, to the local file system) allows you to mount a remote computer (or server) to a local device.

Note: This article assumes that you understand how SSH works and configure SSH in your system.

 

Preparation

Before using SSHfs for mounting, you need to make some settings-install SSHfs and fuse software packages on your system. You also need to create a group for fuse, add users to the group, and create a directory where the remote file system will reside.

To install two software packages on Ubuntu Linux, enter the following command in the terminal window:

  1. sudoapt-get install sshfs fuse

Install sshfs-fuse in ubuntu

If you are not using Ubuntu, search for the package name in your release package manager. It is best to search for keywords related to fuse or SSHfs, because the package name may be slightly different depending on the system you are running.

After installing the software package on your system, you should create a fuse group. When you install fuse, you should create a group on your system. If not, enter the following command in the terminal window to create a group in your Linux system:

  1. sudogroupadd fuse

After adding a group, add your users to the group.

  1. sudo gpasswd -a "$USER" fuse

Sshfs adds users to the group fuse

Don't worry about$USER. Shell will be automatically replaced with your own user name. After processing the group-related work, it is time to create a directory to mount remote files.

  1. mkdir~/remote_folder

After creating a local directory on your system, you can mount the remote file system through SSHfs.

 

Mount a Remote File System

To mount a remote file system on your machine, enter a long command in the terminal window.

  1. sshfs -o idmap=user username@ip.address:/remote/file/system/~/remote

Sshfs mount the file system to the local directory 1

Note: You can also mount the SSHfs file system through an SSH key file. You only need to usesshfs -o IdentityFile=~/.ssh/keyfile, Replacesshfs -o idmap=user.

After entering this command, you will be prompted to enter the remote user password. If the logon succeeds, your remote file system will be mounted to~/remote_folderDirectory.

Sshfs mount the file system to the local directory 2

After using your remote file system, do you want to uninstall it? Is it easy? Enter the following command on the terminal:

  1. sudoumount~/remote_folder

This simple command will disconnect the remote connection and clear the remote_folder directory.

 

Summary

There are many tools in Linux that can be used to access remote files and mount them locally. However, as mentioned earlier, only a few tools can make full use of the powerful functions of SSH. I hope that with the help of this Guide, I can also understand how powerful SSHfs is.

What do you think about SSHfs? Let us know in the comment box below!

Via: https://www.maketecheasier.com/sshfs-mount-remote-filesystem-linux/

Author: Derrik Diener Translator: ictlyh Proofreader: wxy

This article was originally compiled by LCTT and launched with the honor of Linux in China

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.