Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to mount a remote file system using SSH in Linux

Shulou Source: shulou.com Published: 2022-06-01 20:52:02 11月13日 Update

In this issue, the editor will bring you about how to mount the remote file system using SSH in Linux. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

Step 1: install fuse-sshfs

For centos/rhel users, fuse sshfs is available under epel repository, so make sure that epel repository is installed on the system. Now execute the following command to install it

On CENTOS/RHELL:

# yum install fuse-sshfs

On Ubuntu and Dabian:

$sudo apt-get update$ sudo apt-get install sshfs

Step 2: Mount the remote directory

Let's mount the remote server directory using sshfs to ensure that the ssh server running on the remote system is connected correctly to the ssh of the system.

First create the mount point

# mkdir / mntssh

Let's mount the remote directory. For this example, we will install the / home/remoteuser directory from the 192.168.1.12 (remote.example.com) system to the local system.

# sshfs laitkor@remote.example.com:/home/remoteuser / opt/mntssh

Sample output

The authenticity of host 'remote.example.com (192.168.1.12)' can't be established.RSA key fingerprint is 77:85:9e:ff:de:2a:ef:49:68:09:9b:dc:f0:f3:09:07.Are you sure you want to continue connecting (yes/no)? Yesremoteuser@remote.example.com's password:

Step 3: verify the installation

After mounting the remote file system on the local mount point, verify it by running the mount command.

# mount / dev/mapper/vg_svr1-lv_root on / type ext4 (rw) proc on / proc type proc (rw) sysfs on / sys type sysfs (rw) devpts on / dev/pts type devpts (rw,gid=5,mode=620) tmpfs on / dev/shm type tmpfs (rw) / dev/sda1 on / boot type ext4 (rw) remoteuser@remote.example.com:/home/remoteuser on / mntssh type fuse.sshfs (rw,nosuid,nodev)

Also navigate to your mount point and you will see the file from the remote system

# cd / mntssh# ls

Step 4: Mount the directory when the system boots

If you want to automatically mount the remote file system each time the system reboots, add the following entry in the / etc / fstab file. Ensure that key-based ssh is installed between the remote and local systems.

Remoteuser@remote.example.com:/home/remoteuser / mntssh fuse.sshfs defaults 0 0

Step 5: uninstall the directory

If your work is done and you no longer need the installed directory, simply uninstall it using the following command.

# umount / mntssh what is the Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-tasking, multi-threaded and multi-CPU operating system, using Linux to run major Unix tools, applications and network protocols.

The above is the editor for you to share how to use SSH to mount the remote file system in Linux. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: System directory file step command run operating system content server user analysis service authentication free professional small and medium inter-task rich content just need Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker Apple MySQL OPPO Reno