Detailed explanation of how to mount remote file systems via SSH on Linux

Detailed explanation of how to mount remote file systems via SSH on Linux

Features of SSHFS:

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

Multithreading: There can be multiple requests on the server

Allow large reads (up to 64k)

Cache directory contents

Step 1: Install fuse-sshfs

For CentOS/RHEL users, fuse-sshfs is available under epel repository, so 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’s mount the remote server directory using sshfs and make sure the remote system is running an ssh server and the ssh connection with the system is working properly.

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 [email protected]:/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

[email protected]'s password:

Step 3: Verify 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)[email protected]:/home/remoteuser on /mntssh type fuse.sshfs (rw,nosuid,nodev)

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

# cd /mntssh

# ls

Step 4: Mount the directory at system boot

If you want to automatically mount the remote file system on every system reboot, add the following entry in /etc/fstab file. Make sure you have key-based ssh installed between the remote and local systems.

[email protected]:/home/remoteuser /mntssh fuse.sshfs defaults 0 0

Step 5: Unmount the directory

If your work ends and you no longer need the mounted directory, then simply uninstall using the following command.

#umount /mntssh

You may also be interested in:
  • Detailed explanation of how to pass password to ssh/scp command in bash script
  • CentOS method to modify the default ssh port number example
  • Detailed installation and use of SSH in Ubuntu environment
  • Instructions for deploying projects to remote machines using the Publish Over SSH plugin in Jenkins
  • CentOS 6.5 configuration ssh key-free login to execute pssh command explanation
  • Ubuntu basic settings: installation and use of openssh-server
  • How to install MySQL via SSH on a CentOS VPS
  • How to configure ssh/sftp and set permissions under Linux operating system
  • Implementation of ssh non-secret communication in linux
  • Explanation of Mac connecting to remote servers through SSH in different terminals

<<:  Understanding and using React useEffect

>>:  js drag and drop table to realize content calculation

Recommend

How to view and configure password expiration on Linux

With the right settings, you can force Linux user...

Element uses scripts to automatically build new components

Table of contents background How does element-ui&...

Tutorial on building file sharing service Samba under CentOS6.5

Samba Services: This content is for reference of ...

How to implement remote connection for Redis under Linux

After installing Redis on Linux, use Java to conn...

Application examples of WeChat applet virtual list

Table of contents Preface What is a virtual list?...

Difference between var and let in JavaScript

Table of contents 1. Scopes are expressed in diff...

How to install mysql on centos and set up remote access

1. Download the mysql repo source $ wget http://r...

Example of using rem to replace px in vue project

Table of contents tool Install the plugin Add a ....

Vue Element front-end application development to obtain back-end data

Table of contents Overview 1. Acquisition and pro...

W3C Tutorial (13): W3C WSDL Activities

Web Services are concerned with application-to-ap...

Solve the scroll-view line break problem of WeChat applet

Today, when I was writing a small program, I used...

MySQL uses binlog logs to implement data recovery

MySQL binlog is a very important log in MySQL log...