A ssh filesystem allows you to mount directories on a remote host without any server side support. For example, doing:

sshfs richard@zarankiewicz.zgib.net: mnt/tmp/

will make the directory mnt/tmp/ appear to have the same contents as your default directory at the host zarankiewicz.zgib.net (your home directory).

The computer which you mount doesn't have to have anything special installed: ie, they can't stop you from doing it. You may need a kernel module on your computer, but it is easy (and probably already there).

This functionality can be very useful for transferring files or merging computers, though it may be prone to failure under high-traffic conditions or other corner-cases. It is probably possible to tune it to work around these cases. One example of this would be that you may want to disable ssh muxing (see DebianNotes/SSH for an example of a script that does this.

There are two implementations of this that I know.

shfs

shfs is older, and what I used in 2003-2004. It requires it's own kernel module and hasn't been developed recently. For these reason, I recommend using the other implementation.

sshfs

sshfs is newer and part of FUSE, a generalized Filesystem in USErspace kernel module.

In order to use it, you have to have the FUSE kernel module. I think it's mostly included by default now. Thus, installing the kernel module shouldn't be a problem (if it is, install fuse-source and use module-assistant to have it build it for you).

Actual mounting is done by the utility sshfs. The utility /usr/bin/fusermount must be executable by the user and setuid root (since you need the mount system calls run as root). fusermount sanity checks to not let users abuse root permissions. On Debian systems, this utility is installed setuid root but only executable by users in the fuse group, which by default contains no one. Before you use it, run

useradd <username> fuse 

to add yourself to the fuse group, and re-login.

Examples follow:

A basic mounting:

sshfs richard@zarankiewicz.zgib.net: mnt/tmp/

You can make use of any aliases in your .ssh/config file:

sshfs zarankiewicz: mnt/tmp/

Any public keys or stuff you have set up for use by the ssh utility directly works as well.

You can mount a directory other than your home directory. For example,

sshfs zarankiewicz:/tmp/ mnt/tmp/      # the absolute path /tmp/
sshfs zarankiewicz:/ mnt/tmp/             # the root of the remote host
sshfs zarankiewicz:research/ mnt/tmp/     # the subdir research/ under your home dir

To unmount a directory:

fusermount -u mnt/tmp/

Look at the man page for sshfs for more info.

DebianNotes/SshFilesystem (last edited 2009-06-27 15:55:56 by SamatJain)