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:
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:
sudogroupadd fuse
After adding a group, add your users to the group.
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.
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.
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:
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: