How to Install and Use SSHFS on CentOS 7
SSHFS is a handy tool to share files securely. It is a filesystem based on the SSH File Transfer Protocol. As all Linux servers have already SSH installed, its very easy to configure and can be used to share files between two or more servers or desktops. You just have to mount the file system and it works like a charm. The idea of sshfs was taken from the SSHFS filesystem distributed with LUFS, which I found very useful. In this tutorial we will see how to install SSHFS with from the CentOS repository with the yum command and also how to compile it from source.
Install SSHFS with yum
Use the following command to install the SSHFS package with yum:
yum install fuse-sshfs
When you installed the package with yum, proceed with the chapter "Mount a remote folder with SSHFS".
Install SSHFS from source
As an alternative (or when you want to get the latest SSHFS version) you can install SSHFS from source. To install SSHFS from source, you have to download the source files by using the following command which we will download from its official website:
Now extract the folder by using the following command:
tar xvf sshfs-2.8.tar.gz
You have to enter the folder with "cd" and then use configure and compile SSHFS:
make && make install
Now let's start using SSHFS as its successfully installed. Make a folder that you want to share with client end. Let's suppose we make a folder in /var/ with name "mnt"
Mount a remote folder with SSHFS
Now I will mount this folder from the remote server. In my case the remote server IP is 192.168.0.10:
sshfs email@example.com:/ /var/mnt/
Now we will check that is this folder mounted on the other side or not ?
One important thing that should be noted here is that this is temporary mount that will be automatically unmouted when you restart the server. If you want a persistent mount then you should add the mount in /etc/fstab or add the mound command into the /etc/rc.local file which gets run at boot.
Unmount a remote folder
You can unmount the folder by using the following command on your server
From the above tutorial, you have successfully installed and configured SSHFS on your server and you can easily mount and unmount folders and share files remotely with your friends on the same network or over the internet. Learn and Enjoy!