How to mount remote ssh filesystem by using sshfs

How to mount remote ssh filesystem by using sshfs

Introduction –

SSH (Secure Shell) is mostly used to login to remote shell (Linux/Unix machine). SSH is protocol to transfer files securely like FTP, but more secure. Transferring files to an from an ssh account can be done using the scp command. What if you could mount a remote folder that you can access using ssh on your local computer? What if you could access files on an ssh account just like they were local files on your pc? Well now you can! mount a folder in an ssh account, edit the files locally and save the files, that’s it! The file will be saved on remote ssh server.

sshfs is a tool, which allow us to mount directory file systems over ssh on Ubuntu. sshfs is a filesystem client based on the SSH File Transfer Protocol.
Most SSH servers already support this protocol it is very easy to set up on the server side there’s nothing to do. On the client side mounting the filesystem is as easy as logging into the server with ssh.

How to install sshfs –

root@arunbagul:~# apt-get  install   sshfs
Reading package lists… Done
Building dependency tree


This will also install fuse-utils and libfuse2, which are required.

What is required ?

fuse is the kernel module which need to loaded –

root@arunbagul:~# lsmod | grep fuse
fuse 47124 3

If this module is not loaded, you will get following error-

fusermount: fuse device not found, try ‘modprobe fuse’ first

** Use below command to load ‘fuse’ module

root@arunbagul:~# modprobe fuse

If you want to load ‘fuse’ modules on startup. Then edit the file /etc/modules and adding a ‘fuse’ on new line at the end.

** Now create a local directory where you want the files to be mounted…

root@arunbagul:~# mkdir /media/ssh_file_system
root@arunbagul:~# chown arun:arun /media/ssh_file_system

Once you have done the above, you can use sshfs to mount the remote directory to your local system!

Say I want to mount the “/var/www” directory on my remote server ( I would do it by executing the following command…

root@arunbagul:~# sshfs root@ /media/ssh_file_system
root@’s password:

** Check with mount command whether the file system is mounted or not

root@arunbagul:~# mount | grep sshfs
sshfs#root@ on /media/ssh_file_system type fuse (rw,nosuid,nodev,max_read=65536)

NOTE – Normal user should be in ‘fuse’ group to mount file system by using sshfs.

root@arunbagul:~# grep fuse /etc/group

** How to unmount the directory –

root@arunbagul:~# mount | grep sshfs
sshfs#root@ on /media/ssh_file_system type fuse (rw,nosuid,nodev,max_read=65536)

root@arunbagul:~# fusermount -u /media/ssh_file_system

root@arunbagul:~# mount | grep sshfs


command(1) fusermount – mount FUSE filesystems. A virtual FUSE filesystem will be created on the mount point.

-h print help

-V print version

-o opt[,opt…]
mount options

-u unmount

-q quiet

-z lazy unmount (works even if resource is still busy)

command(2) SSHFS – filesystem client based on SSH File Transfer Protocol

usage: sshfs [user@]host:[dir] mountpoint [options]

general options:
-o opt,[opt…]
mount options

-h –help
print help

-V –version
print version

-p PORT equivalent to ‘-o port=PORT’

Arun Bagul

Similar Posts:

Leave a Reply

Your email address will not be published.