Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to mount a remote directory over ssh using 'sshfs'  (Read 2381 times)

0 Members and 1 Guest are viewing this topic.

lijeshk

  • Guest
How to mount a remote directory over ssh using 'sshfs'
« on: November 03, 2013, 09:37:56 am »
Mounting a remote folder over ssh is handled by FUSE kernel module, which allows one to create a virtual file system in user space. sshfs and gvfs are two such virtual file systems built on FUSE that allow one to mount a remote file system over ssh.  Pleased follow the given steps to mount a remote directory over ssh with sshfs

To install sshfs on Ubuntu or Debian:

#sudo apt-get install sshfs

To install sshfs on CentOS, RHEL :

#yum install sshfs

If you want to use sshfs as a non-root user, you need to add the user to a group called fuse:

#sudo usermod -a -G fuse <user_name>

Run the following to make group membership change activated:
 
#exec su -l $USER

Then you can mount a remote directory using sshfs as follows:

#sshfs user@remote-host:/directory <local_mount_point>

If you want to set up passwordless mounting, all you have to do is to set up passwordless ssh login to user@remote-host

To unmount a ssh-mounted directory, please do the following:

#fusermount -u <local_mount_point>

If you need to mount the remote directory permanently, you need to do the following:
 
  • First you need to set up passwordless ssh login to the remote server
  • Then add the following in to the /etc/fstab of our local machine.
             #vi /etc/fstab
                 sshfs#user@remote-host:/directorytomount <local_mount_point> fuse user 0 0

--

 :)