Log in

Registration

Mount Remote Filesystems via SSH

Posted: August 3, 2010 / in: Nuts and Bolts / No comments

fuse-logo.pngLinux provides a powerful feature to integrate remote filesystems into your local one. And if you are required to provide this privilege to non-admin users the kernel extention FUSE might be the tool you are looking for.

This article introduces FUSE and describes how to use it.

FUSE

Integrating and decoupling file systems is reserved for administrative users by default and supported file systems have to be integrated in the Linux kernel. With FUSE things did change. FUSE allows non-admin users to mount custom file systems. And the file system driver may run in a userspace program. So any user will be able to map (remote) resources into the local file system.

Installation

To install FUSE modern Linux Distributions come with pre-package software. You just have to install the FUSE package and the desired file system driver. 

When utilizing Debian-based distributions like Ubuntu you are just required to install the sshfs software package. This can be performed by executing the following command line statement.

# To mount local/remote file systems with FUSE via ssh # you have to install sshfs $ sudo apt-get install sshfs 

Configuration

After the installaton has been completed successfully you may start to mount file systems. However, FUSE comes with some global settings, that may be of interest for productive systems. As an alternative you can utilize the appropriate command line parameters when mounting file systems.

The file /etc/fuse.conf might contain the following entries.

user_allow_other

FUSE prevents other users to access your mounted file systems. If your want to lift this restriction you may add ‘user_allow_other’ to the configuration file or you could mount the file system with the “-oallow_other” or “-oallow_root” mount option.

mount_max

Set the maximum number of FUSE mounts allowed to non-root users (default is 1000). To modify the default value add ‘mount_max = <number>‘ to the configuration file.

The following example shows the default configuration in /etc/fuse.conf.

 

# Set the maximum number of FUSE mounts allowed to non-root users.# The default is 1000.#mount_max = 1000 # Allow non-root users to specify the 'allow_other' or 'allow_root'# mount options.#user_allow_other 

 

Mount File Systems

The following example shows you how to utilize the command line to mount local or remote file systems.

 

# default pattern to mount remote file systems$ sshfs -o idmap=user user@host:/path/to/remote/dir /path/to/local/mountpoint # a real life example - mount a local subdirectory$ mkdir ~/my-mnt$ sshfs -o idmap=user $USER@localhost:/etc ~/my-mntmario@localhost's password: # ... or the 'short' variant:$ sshfs localhost:/etc ~/my-mntmario@localhost's password: # mount a full file system tree from a remote machine$ mkdir ~/host-remote$ sshfs -o idmap=user -o allow_root ro-user@remotehost:/ ~/host-remotero-user@remotehost's password: 

 

Unmount File Systems

To unmount a previously mounted device just execute one of the following commands.

# unmount a FUSE file system$ umount /path/to/mountpoint # ...or use this command$ fusermount -u /path/to/mountpoint 

 

Mount at Boot Time

To mount FUSE file systems at boot time you can add the following command to your file /etc/fstab.

# add to /etc/fstab to mount filesystems at boot time# example entry:sshfs#user@host:/    /mnt/host    fuse    defaults    0 0 

 

 

Related articles:

Related resources:

© Copyrights and Licenses, 2012 - Linux-Support.com The Professional Linux and OSS Services Portal