next up previous
Next: Getting information Up: Linux/UNIX Previous: File locations

Mounting remote UNIX/Linux directories via ssh tunnelling

There are a couple relatively easy ways to mount remote directories on your local Linux box without needing to change anything on the server side. The result is that the files appear to be local and can be worked with as if they were local (e.g., opening files, copying, etc.). Both of these approaches send the files through ssh, so everything is secure and as long as the server accepts ssh sessions, this should work with any UNIX/Linux server.

  1. Install the sshfs package. Then just create a local directory; this will serve as the mount point for the remote filesystem. Finally, as the user, rather than root, do the following, where mountpoint is the local directory you created.
    >sshfs hostname: mountpoint 
    I've noticed a few minor problems when using sshfs, but the advantages have outweighed the disadvantages. There are occasionally issues with using mv rather than cp, and sometimes things freeze. Also, on my Fedora 5 machine, I've needed to invoke the following command before invoking sshfs
    >su -c 'mknod -m 666 /dev/fuse c 10 229; chmod guo+rw /dev/fuse' 
    To unmount the filesystem, just do 
    >fusermount -u mountpoint
  2. Use the shfs package, which provides shfsmount and shfsumount binaries for mounting and unmounting directories. These binaries tunnel through ssh so that everything is completely secure, removing the need for SAMBA or something similar to be running on the file server/remote machine. In my Linux Redhat 9 installation, it took some monkeying to get shfs to install properly. First, shfs needs to work with the current version of the kernel, so it requires that the kernel-source package for the current kernel be installed. I also needed to make a couple changes to the Makefile when installing the package, namely defining KERNEL=$(uname -r) and KERNEL_SOURCES=${ROOT}/usr/src/linux-2.4.

    You will also need to chmod 4555 /usr/bin/shfs{u}mount so that individual users can access the binaries.

    If you update your kernel, you'll need to reinstall shfs, along the following lines:

    >cd /opt/shfs-0.35

    >make clean # this may not be necessary

    >make # this may not be necessary

    >make install

    >chmod 4555 /usr/bin/shfs{u}mount

Keywords: remote mounting, ssh, tunneling

Last modified: 12/28/07 (sshfs), 4/2/06 (shfs)


next up previous
Next: Getting information Up: Linux/UNIX Previous: File locations
Chris Paciorek 2012-01-21