Home  >  Article  >  Operation and Maintenance  >  Mount remote file system via SSH on Linux

Mount remote file system via SSH on Linux

不言
不言Original
2019-03-16 15:39:043023browse

SSHFS is a file system based on SSH File Transfer Protocol (SFTP). On the remote side we only need to install the SSH server, as most SSH servers already support this, so there is nothing to do on the remote server other than installing the SSH server. On the client side, we need to install the fuse sshfs package to mount the remote file system.

Mount remote file system via SSH on Linux

Features of SSHFS:

Based on FUSE (the best user space file system framework for Linux)

Multi-threading: There can be multiple requests on the server

Allow large reads (max 64k)

Cache directory contents

Step 1: Install fuse-sshfs

For centos/rhel users, fuse sshfs is available under epel repository, so please make sure you have epel repository installed in your 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 us use sshfs to mount the remote server directory and ensure that the ssh server running on the remote system is properly connected to the system's ssh.

First create the mount point

# mkdir /mntssh

Let’s mount the remote directory. For this example, we will mount 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)? yes
remoteuser@remote.example.com's password:

Step 3: Verify installation

After mounting the remote file system on the local mount point, pass Run the mount command to verify.

# 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)

Similarly navigate to your mount point and you will see the files from the remote system

# cd /mntssh
# ls

Step 4: Mount the directory on system boot

If you want the remote file system to be automatically mounted every time the system reboots, add the following entry in the /etc/fstab file. Make sure you have key-based ssh 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 over and you no longer need the mounted directory, just uninstall it using the following command.

#umount / mntssh

This article has ended here. For more exciting content, you can pay attention to other related column tutorials on the php Chinese website! ! !

The above is the detailed content of Mount remote file system via SSH on Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn