How to mount a remote directory in Linux using sshfs

Q. I have access rights to one of the remote server through SSH protocol and there is no File share services such as Samba, NFS or FTP etc which are enabled on the server. Now I want to mount data from that remote server, is it possible to mount remote folders?

A. The answer to this is yes, We can share data/mount folder on a local machine by using just SSH protocol. This can be done by using FUSE(Filesystem in USErspace) which support SSH and FTP file systems. This post is in response to conversation which I had with one our users two days back. the question he asked about ftp is “I want to transfer one latest file from my ftp server and I want to automate this task through shell script to download latest file from my FTP server, And I don’t know what is the Operating System at server end(This is ultimate sentence I hear from the user today in my office :) )“. Let’s prepare our machine on how to mount a remote folder by using SSH protocol.

Step1: Installing Package

On Ubuntu/Debain

apt-get install sshfs

On Redhat/CentOS/Fedora

rpm -ivh fuse-sshfs-1.8-1.el5.rf.i386.rpm

Step2: Once the package is installed we have to create a mount point and mount our  server data using sshfs command, for which we require  username/password. Here are my details for this task.

My Username: root

My password: redhat

My Server:

My mount point: /mnt/ssh

Now create the mount point and mount SSH account data.

#mkdir /mnt/ssh

#sshfs [email protected]:/ /mnt/ssh/

[email protected]'s password:

Step3: The above command will mount my root directory in server. Testing our setup

Check if you are able to see data

#cd /mnt/ssh


Sample output

bin   cdrom     data  etc   initrd.img      lib         media  opt   root  selinux  sys   tmp  var      vmlinuz.old
boot  cmdb-bkp  dev   home  initrd.img.old  lost+found  mnt    proc  sbin  srv      test  usr  vmlinuz

What about df -hs command output?

Sample output

Filesystem Size Used Avail Use% Mounted on
/dev/sda2 12G 8.4G 2.5G 78% /
/dev/sda6 80G 43G 34G 56% /var
/dev/sda5 2.0G 41M 1.8G 3% /home
/dev/sda1 99M 12M 83M 12% /boot
tmpfs 506M 0 506M 0% /dev/shm
[email protected]:/ 1000G 0 1000G 0% /mnt/ssh

Step4: So what about mounting it permanently?. We can do it by editing fstab file in /etc folder

#vi /etc/fstab

go to last line and type below line

[email protected]:/ /mnt/ssh fuse defaults 0 0

Save the file and exit. Now run mount -a to update the fstab file state to kernel.

Note: Its not advisable to write passwords in human readable files like /etc/fstab.

#mount -a

Let me explain what entry in fstab indicates. We are mentioning mount user root data which is located on server on to /mnt/ssh using fuse file system with default settings.

Step5: What about unmounting this drive?

#umount /mnt/ssh

Enjoy new learning of mounting a folder using SSH protocol.

Show your love by sharing this..!
Share on VKShare on StumbleUponShare on YummlyPrint this pageFlattr the authorShare on TumblrEmail this to someoneBuffer this pageShare on Google+Share on LinkedInShare on FacebookTweet about this on TwitterPin on PinterestShare on RedditDigg this
The following two tabs change content below.
My name is Surendra Kumar Anne. I hail from Vijayawada which is capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. I work with ICE systems, Sydney as Sr. Consultant. You can contact me at surendra (@) linuxnix dot com.
  • Vamsireloaded

    xcellent tuts..thank u 

    • Surendra

      @Vamsi wlcom buddy..

  • Sonia Hamilton

    Nice, thanks!

    • Surendra

      wlcm Sonia


  • Sonia Hamilton

    Nice, thanks!

    • Surendra

      wlcm Sonia


  • Pingback: How to mount a remote directory using SSH via SSHFS » Kip - Knowledge Is Power()

  • Pawan_tumuluri

    Today i learn new thing about SSHFS pkg thqs for posting . keep going 

  • vahid chakoshy

    very nice. thanks.

  • Hamza Thekethil

    superb tuto….!!!!!!

  • predatorian3

    I keep getting an error message that says: ‘read: Connection reset by peer.’

    • predatorian3

      Never mind, upon further investigation, I replied too soon. Its a firewall issue.

  • Pingback: Mount remote Linux Directories in Linux: SSHFS | Pred-Tech()

  • J. Vincent Nix, PhD (@jvincentnix)

    that all works fine, thank you!

    but when I try to point my Transmission to a folder there, for downloads, I cannot browse to the directory. What am I missing? Nothing shows up in my /home/user/.gvfs folder either. Thanks in advance.

    • Surendra Anne

      Did you have permissions on that remote folder?

  • caman luc

    This website is awsome. only one thing, how do I search a topic using keyword. I don’t seem to find any search/find button anywhere

  • J-F Bohemier

    umount might not work… if that’S the case, you can use fusermount -u /mnt/ssh


  • John

    Great tutorial. I’ve been struggling to connect from Linux Mint to an Ubuntu VM with Samba. This is so much simpler.

    • Surendra Anne

      Welcome John.