SSHFS in Linux

SSHFS stands for (Secure SHell FileSystem) client that enable us to mount remote filesystemand interact with remote directories and files on a local machine using SSH File Transfer Protocol(SFTP).

SFTP is a secure file transfer protocol that provides file access, file transfer and file
management features over Secure Shell protocol.Because SSH uses encryption while transferring files over the network from one computer to another computer and SSHFS comes with built-inFUSE (Filesystem in Userspace) kernel module that allows any non-privileged users to create theirfile system without modifying kernel code.

Install SSHFS in RHEL, CentOS and Fedora

Step 1: Installing SSHFS

By default sshfs packages exists on all major Linux distributions, just use the below Yum command
to install it with their dependencies.

# yum install sshfs

Step 2: Creating SSHFS Mount Directory

Once the sshfs package installed, you need to create a mount point directory where you will mount your remote file system. For example, we have created mount directory under /mnt/sshfs.

# mkdir /mnt/sshfs

Step 3: Mounting Remote Filesystem with SSHFS

Once you have created your mount point directory, now run the following command as a root user to mount remote file system under /mnt/tecmint. In your case the mount directory would be anything.
 The following command will mount remote directory called /home/tecmint under /mnt/tecmint inlocal system.

# sshfs user@x.x.x.x:/home/sshfs/ /mnt/sshfs

Step 4: Verifying Remote Filesystem is Mounted

If you have run the above command successfully without any errors, you will see the list of remote
files and directories mounted under /mnt/sshfs.

# cd /mnt/sshfs

# ls

[root@ sshfs]# ls

12345.jpg                       ffmpeg-php-0.6.0.tbz2 


Step 5: Checking Mount Point with df -hT Command

If you run df -hT command you will see the remote file system mount point.

 # df -hT

[root@tecmint]# df -hT

Filesystem   Type    Size      Used    Avail   Use%     Mounted on

/dev/sda2 ext3         75G      21G     51G      29%       /

/dev/sda5   ext3       24G      21G    1.5G      94%      /home

/dev/sda3   ext3       29G      25G    2.6G      91%      /data

/dev/sda1   ext3       289M   22M   253M    8%         /boot

tmpfs         tmpfs     252M    0        252M   0%        /dev/shm

sshfs#user@ fuse 457G 129G 305G 30% /mnt/sshfs

Step 6: Mounting Remote Filesystem Permanently

To mount remote filesystem permanently, you need to edit the file called /etc/fstab. To do, open the file with your favorite editor.

 # vi /etc/fstab

Go to the bottom of the file and add the following line to it and save the file and exit. The below entry mount remote server file system with default settings.

sshfs#user@x.x.x.x:/home/sshfs/ /mnt/sshfs fuse defaults 0 0

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

# mount -a

Step 7: Unmounting Remote Filesystem

To unmount remote filesystem, issue the following command it will unmount the remote file system.

# umount /mnt/sshfs


About Manish Jha

Hi All I am Manish Kumar Jha aka Alex Hunt. I am currently working in VMware Software India Pvt Ltd as Operations System Engineer (vCloud Air Operations). I have around 5 Years of IT experience and have exposure on VMware vSphere, vCloud Director, RHEL and modern data center technologies like Cisco UCS and Cisco Nexus 1000v and NSX. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.
This entry was posted in Linux/CentOS. Bookmark the permalink.

One Response to SSHFS in Linux

  1. Pingback: Link: How to use sshfs (Secure Shell FileSystem) to Mount Remote Directories Locally » TechNotes

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s