Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use SSHfs to mount a remote file system to a local directory on Ubuntu

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to mount a remote file system to a local directory using SSHfs on Ubuntu". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to mount a remote file system to a local directory using SSHfs on Ubuntu.

The world outside windows is much bigger than expected. I use ssh almost every day, but I only know that there is such a good thing as sshfs. A few days ago, I was glad and ashamed that ZendStudio could edit documents remotely. Finally, there is a more convenient way than vi scp://hostname//path/to/file.

Sshfs, the host resource to which ssh can be connected, is mapped to the local file system, and then the user can operate as if it were a local file, and the actual file changes will be transferred to the remote host through ssh. It's like mount has a windows share directory, or a samba share of another linux host, or a nfs share, except that the "sharing protocol" becomes a ssh channel.

Sshfs is already included in the ubuntu source, and the required fuse packages can be installed directly with apt. There are three packages in total: "fuse-utils libfuse2 sshfs", which adds up to only 179k. A user group fuse is automatically created during installation. Users who want to use sshfs need to be added to this user group first (remember to log in again after completion), otherwise they will not have permission to execute fusermount:

Fuse: failed to exec fusermount: Permission denied

The code is as follows:

Mkdir ~ / remote_folder

Once you have created 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, you need to enter a longer command in the terminal window.

The code is as follows:

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

Note: you can also mount the SSHfs file system through the SSH key file. Just replace the sshfs-o idmap=user section with sshfs-o IdentityFile=~/.ssh/keyfile in the above hit.

After entering this command, you will be prompted to enter the password of the remote user. If the login is successful, your remote file system will be mounted to the previously created ~ / remote_folder directory.

After using your remote file system, do you want to unmount it? Is it easy? Just enter the following command at the terminal:

The code is as follows:

Sudo umount ~ / remote_folder

This simple command disconnects the remote connection and empties the remote_folder directory.

Summary

There are many tools on Linux that can be used to access remote files and mount them locally. But as mentioned before, there are very few tools that, if any, can take full advantage of the power of SSH. I hope that with the help of this guide, I can also realize how powerful a tool SSHfs is.

At this point, I believe you have a deeper understanding of "how to use SSHfs to mount a remote file system to a local directory on Ubuntu". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report