How to Mount Remote Partition via SSH on CentOS
2 mins read

How to Mount Remote Partition via SSH on CentOS

Description about SSHFS 

SSHFS (SSH Filesystem) is a filesystem client to mount and interact with directories and files located on a remote server or workstation over a normal ssh connection.

The client interacts with the remote file system via the SSH File Transfer Protocol (SFTP), a network protocol providing file access, file transfer, and file management functionality over any reliable data stream that was designed as an extension of the Secure Shell protocol (SSH) version 2.0.

SFTP provides secure file transfer and a secure remote file system.

While SFTP clients may transfer files and directories, the related file system may not be mounted locally using SFTP alone

Using SSHFS, a remote file system may be treated in the same way as other volumes (such as CDs, DVDs, USB flash drives and shared disks).

We can easily mount a remote file system by using SSHFS.

 

Step 1. Enable the EPEL repo

We will need to install a few packages that are not available in the standard CentOS repository.

In order to do this we must enable the EPEL repo, click on Link to know about enable the EPEL repo.

 

Step 2. Install FUSE and SSHFS packages

SSHFS uses FUSE (Filesystem in Userspace). Install the required packages

[root@vps ~]# yum install fuse sshfs

 

Step 3. Load the FUSE module

[root@vps ~]# modprobe fuse

 

Confirm that the FUSE module is loaded :

[root@vps ~]# lsmod | grep fuse
fuse         84368      2

 

Make sure the FUSE module is loaded upon a reboot :

[root@vps ~]# echo "modprobe fuse" >> /etc/rc.local

 

Step 4. Using SSHFS

Once the FUSE module is loaded, we can finally mount our remote partition using SSHFS :

[root@vps ~]# sshfs user@remote_host:/remote_directory /local_mount_partition

 

[root@vps ~]# sshfs root@1.2.3.4:/scripts /mnt

 

Note: SSHFS is not recommended for production, distributed file-systems.

NFS is a better option, however, SSHFS can still be quite useful.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *