Cloud Storage with SSHFS + Linux

by Billel LASLEDJ


Posted on January 21, 2015 at 11:00 PM



Do you want to run your own secure cloud storage ! or coding apps remotely and you find yourself uploading a script repeatedly to your virtual server to test!. Luckily there is a way to mount your VPS file system to your local computer, so you can make changes on the fly and treat your droplet as local storage. I'm going to share with you my own experience using SSH to create a secure remotely mounted network filesystem with Linux.

In computing, SSHFS (SSH Filesystem) is a filesystem client to mount and interact with directories and files located on a remote server or workstation. 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. – Wikipedia

Installing SSHFS

Assuming that you have an SSH server running on your machine and you need an IP address and the default port (22) to connect to your cloud storage. Note that if you run this Linux at home (like I do) you need to forward TCP port 22 on your broadband modem/router to your machine. , in the setup is quite simple. As a Gentoo user :

emerge -av sshfs-fuse

On Ubuntu and Debian based systems it can be installed through apt-get.

sudo apt-get install sshfs

Once SSHFS has been installed you're almost ready to mount the remote file system.


Mounting

Before attempting to mount a directory, make sure the file permissions on the target directory allow your user correct access. Simply run the SSHFS command to mount the remote directory on your local file system:

sshfs account@ip:remoteFolderFullPath localFolderPath
for example:
sshfs bilo@billel.zapto.org:storage ~/sshfsmount
If you need to enter a password sshfs will ask for it(ssh which ask for the password if needed).
To unmount,
fusermount -u ~/sshfsmount

To add it to your /etc/fstab,

sshfs#bilo@billel.zapto.org:storage /home/bilo/sshfsmount fuse users 0 0
like that you can access directly by executing the command mount sshfsmount instead of the whole mount line.

Congratulations. You now have sshfs working!


References

Linux: How to mount remote storage “on-demand”
HOWTO: sshfs in gentoo (sshfs-fuse)
How To Use SSHFS to Mount Remote File Systems Over SSH
SSHFS + Linux = SFTP powered cloud storage

Blog Categories

Cloud storage

Cloud storage is an industry term for managed data storage through hosted network (typically Internet-based) service. Several types of cloud storage systems have been developed supporting both personal and business uses.