In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to mount a remote file system using SSHFS under Linux, which has a certain reference value. Interested friends can refer to it. I hope you can learn a lot after reading this article.
SSHFS is a network file system client that connects to the server through SSH. SSHFS allows you to mount a remote file system using SFTP. Most VPS SSH servers support and enable this SFTP access by default, so SSHFS is very simple to use and requires no action on the server side.
Step 1: install SSHFS on the Linux system
By default, the sshfs package does not exist in all major Linux distributions, so you need to enable epel on your Linux system and install SSHFS and its dependencies with the help of the Yum command line.
# yum install sshfs# dnf install sshfs [on Fedora 22 + release] $sudo apt-get install sshfs [Debian/Ubuntu-based system] step 2: create a SSHFS mount directory
After you install the SSHFS package, you need to create a mount point directory where you will mount your remote file system. For example, we create a mount directory under / mnt/tecmint.
# mkdir / mnt/tecmint$ sudo mkdir / mnt/tecmint [Debian/Ubuntu-based system] step 3: Mount a remote file system using SSHFS
After you have created your mount point directory, now use the root user to run the following command line to mount the remote file system under the / mnt/tecmint directory. Depending on your situation, the mount directory can be any directory.
The following command line will mount a / home/tecmint directory called remote under the local / mnt/tecmint directory. Don't forget to replace x.x.x.x with your IP address and mount point.
# sshfs tecmint@x.x.x.x:/home/tecmint/ / mnt/tecmint$ sudo sshfs-o allow_other tecmint@x.x.x.x:/home/tecmint/ / mnt/tecmint [Debian/Ubuntu-based system]
If your Linux server is configured to be based on SSH key authorization, you will need to specify the path to your public key using the command line shown below.
# sshfs-o IdentityFile=~/.ssh/id_rsa tecmint@x.x.x.x:/home/tecmint/ / mnt/tecmint$ sudo sshfs-o allow_other,IdentityFile=~/.ssh/id_rsa tecmint@x.x.x.x:/home/tecmint/ / mnt/tecmint [Debian/Ubuntu-based system] step 4: verify that the remote file system is mounted successfully
If you have successfully run the above command without any errors, you will see a list of remote files and directories mounted in the / mnt/tecmint directory
# cd / mnt/tecmint# ls [root@ tecmint] # ls12345.jpg ffmpeg-php-0.6.0.tbz2 Linux news-closeup.xsl s3.jpgcmslogs gmd-latest.sql.tar.bz2 Malware Newsletter1.html sshdallowepel-release-6-5.noarch.rpm json-1.2.1 movies_list.php pollbeta.sqlffmpeg-php-0.6.0 json-1.2.1.tgz my_next_artical_v2.php Pollbeta.tar.bz2 step 5: check the mount point using the df-hT command
If you run the df-hT command, you will see the mount point of the remote file system.
# df-hT
Sample output:
Filesystem Type Size Used Avail Use% Mounted onudev devtmpfs 730M 0730M 0% / devtmpfs tmpfs 150M 4.9M 145m 4% / run/dev/sda1 ext4 31G 5.5G 24G 19% / tmpfs Tmpfs 749M 216K 748m 1% / dev/shmtmpfs tmpfs 5.0M 4.0K 5.0M 1% / run/locktmpfs tmpfs 749M 0749m 0% / sys/fs/cgrouptmpfs tmpfs 150M 44K 150m 1 % / run/user/1000tecmint@192.168.0.102:/home/tecmint fuse.sshfs 324G 55G 253G 18% / mnt/tecmint step 6: permanently mount the remote file system
In order to permanently mount the remote file system, you need to modify a file called / etc/fstab. Follow suit and open the file using your favorite editor.
# vi / etc/fstab$ sudo vi / etc/fstab [Debian/Ubuntu-based system]
Move to the bottom of the file and add the following line to save the file and exit. The following entry indicates that the remote file system is mounted using the default settings.
Sshfs#tecmint@x.x.x.x:/home/tecmint/ / mnt/tecmint fuse.sshfs defaults 0 0
Make sure that SSH is allowed to log in without a password between the servers so that the file system can be automatically mounted after the system is rebooted.
If your server is configured for authentication based on SSH key, please add the following line:
Sshfs#tecmint@x.x.x.x:/home/tecmint/ / mnt/tecmint fuse.sshfs IdentityFile=~/.ssh/id_rsa defaults 0 0
Next, you need to update the fstab file for the changes to take effect.
# mount-a $sudo mount-a [Debian/Ubuntu-based system] step 7: unmount the remote file system
To unmount the remote file system, simply issue the following command.
# umount / mnt/**tecmint** Thank you for reading this article carefully. I hope the article "how to mount a remote file system using SSHFS under Linux" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.