Under Linux we typically use SSH commands to log on to a remote Linux server, and if more than one remote server needs to log in, the process of switching back and forth will become cumbersome. If you use SSHFS, you will be able to map the remote directory directly to the local without modifying the settings of the remote computer. Let's take a look at how to use SSHFS.
First, we need to install the SSHFS software. SSHFS is a file system client based on the SSH file Transfer Protocol, and its official webpage is: http://fuse.sourceforge.net/sshfs.html. Under CentOS, we can install it via Yum (note that installing the Epel source is required for Yum installation):
yum-y Install FUSE-SSHFS
After installation, the system will automatically establish a fuse user group, users who want to use SSHFS simply join this user group.
To mount a remote directory, use the following command:
SSHFS [email protected]:p ath Mout_point
Here user is the remote host username, hostname is the remote host IP address, path is the remote host to mount to the local directory, Mount_point is mounted to the local directory.
When not in use, use the following command to uninstall:
fusermount-u Mount_point
If you want to mount the boot automatically, you can add the following line to the/etc/fstab:
sshfs#[email protected]:p ath Mount_point fuse defaults,auto,allow_other 0 0
This requires that SSH automatic login is configured, so that the root user can log on to the remote host using the user, the other allow_other this parameter is very important, without this parameter, the attached directory only root can access.
To mount a remote directory to a local using SSHFS