Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: SSHFS: Mount Remote Linux Filesystems  (Read 2896 times)

0 Members and 1 Guest are viewing this topic.

Vinil

  • Guest
SSHFS: Mount Remote Linux Filesystems
« on: January 14, 2014, 12:24:42 pm »
SSHFS stands for (Secure SHell FileSystem) client that enable us to mount remote filesystem and interact with remote directories and files on a local machine using SSH File Transfer Protocol (SFTP).

Because SSH uses encryption while transferring files over the network from one computer to another computer and SSHFS comes with built-in FUSE (Filesystem in Userspace) kernel module that allows any non-privileged users to create their file system without modifying kernel code.

Install SSHFS in RHEL, CentOS and Fedora

Step 1: Installing SSHFS

# yum install sshfs


Step 2: Creating SSHFS Mount Directory

# mkdir /mnt/local_sshfs_dir


Step 3: Mounting Remote Filesystem with SSHFS

# sshfs username@x.x.x.x:/home/remote_sshfs_dir/ /mnt/local_sshfs_dir


Step 4: Verifying Remote Filesystem is Mounted

Quote
# cd /mnt/local_sshfs_dir
# ls

For example:
Code: [Select]
# cd /mnt/local_sshfs_dir; ls

./             cgi-bin/       cron.php            .gitignore  index.php          install.php         LICENSE.txt      modules/    robots.txt  themes/      web.config
../            CHANGELOG.txt  drupal-7.22.bak/    .htaccess   INSTALL.mysql.txt  INSTALL.sqlite.txt  MAINTAINERS.txt  profiles/   scripts/    update.php   xmlrpc.php
authorize.php  COPYRIGHT.txt  drupal-7.22.tar.gz  includes/   INSTALL.pgsql.txt  INSTALL.txt         misc/            README.txt  sites/      UPGRADE.txt


Mounting Remote Filesystem Permanently

To mount remote filesystem permanently, you need to edit the file called /etc/fstab and add the following.

Code: [Select]
# vi /etc/fstab

sshfs username@x.x.x.x:/home/remote_sshfs_dir/  /mnt/local_sshfs_dir  fuse  defaults  0  0


Next, you need to update the fstab file to reflect the changes.

# mount -a


To unmount:

# umount /mnt/local_sshfs_dir