Mount Remote Filesystems Over SSH Using SSHFS
We, all, use NFS, Samba and OpenAFS to mount and access remote file systems over network. Unfortunately we need administrative privileges on both side to setup NFS, Samba or OpenAFS servers. No more worries, we can now mount and access remote file systems without any additional software using SSHFS. Since all modern operating system supports SSH, we can easily mount and access remote filesystem trees on our local system.
SSHFS is a filesystem client based on the SSH File Transfer Protocol. Since most SSH servers already support this protocol it is very easy to set up. On the client side mounting the filesystem is as easy as logging into the server with ssh. We don’t have to do any setup or configuration on the server side. All you need is the remote server should have a working SSH server.
- Based on FUSE (the best userspace filesystem framework for linux ;-)
- Multithreading: more than one request can be on it’s way to the server
- Allowing large reads (max 64k)
- Caching directory contents
Install SSHFS On Linux
SSHFS is available in the default repositories of Debian/Ubuntu and it’s derivatives. So we can install it with root privileges using command:
# apt-get install sshfs
SSHFS is not available in the default repositories. So let us add EPEL repository to install SSHFS.
To add EPEL repository on RHEL/CentOS 6.x systems, go to the EPEL website, download and install as shown below.
# rpm -Uvh http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm
Now update package lists and install sshfs as shown below.
# yum update # yum install sshfs
The usage is very simple.
$ sshfs hostname-of-remote-system:<directory-path> mountpoint
$ sshfs ip-address-of-remote-system:<directory-path> mountpoint
Please note that you don’t need to be a root user to mount remote filesystems using SSHFS. Just log in as a regular user and mount the remote filesystem.
For example, I am going to mount my Debian server directory to my local Ubuntu desktop.
Create a mount point on local system.
$ mkdir /home/sk/sshfs/
Mount the remote system directory on /home/sk/sshfs/ directory using command:
$ sshfs email@example.com:/ /home/sk/sshfs/
In the above i mounted the root(/) directory of my remote Debian server to my Ubuntu Desktop.
192.168.1.200 – Debian server IP address.
/ – My Debian server root directory which is going to be mounted on local system.
/home/sk/sshfs – My local Ubuntu system mount point.
Now you can check whether the remote system directory is mounted either using Terminal:
$ df -h
Filesystem Size Used Avail Use% Mounted on /dev/sda1 292G 238G 40G 86% / none 4.0K 0 4.0K 0% /sys/fs/cgroup udev 989M 12K 989M 1% /dev tmpfs 200M 872K 199M 1% /run none 5.0M 0 5.0M 0% /run/lock none 998M 6.7M 991M 1% /run/shm none 100M 20K 100M 1% /run/user firstname.lastname@example.org:/ 19G 16G 2.0G 89% /home/sk/sshfs
or you can check from your file manager.
$ fusermount -u /home/sk/sshfs
For more detailed information please look into the official FAQ page.