Wednesday, April 2, 2008

SSHFS via Fuse

This is relatively new to me and pretty damn cool. FUSE (Filesysten in Userspace) is a software package which allows you to mount various types of filesystems from inside userspace. It also includes an API for integrating such functionality into your own software and all sorts of other goodies, but that's beyond the scope of this post. I'm constantly hopping between the Grooveshark dev server and my local machine. Thinking it would be really convenient to have the remote filesystem available from inside my home directory, I decided to give Fuse a try. On my local Ubuntu workstation the sequence went something like this:

desktop:~$ apt-get install fuse-utils sshfs
desktop:~# usermod -a -G fuse travis # add my user to the fuse group
... logout ... log back in ...
desktop:~$ mkdir devmnt
desktop:~$ sshfs -p someport -oIdentityFile=/path/to/id/file user@host:/ devmnt
desktop:~$ cd devmnt
desktop:~/devmnt$ ls
... files !...

If you don't use an identity file or alternative port to ssh, you can omit those options from the sshfs command-line. Also, the filesystem is mounted with the same privileges as if you were logged onto the box as the user specified... so you can read and write files at will so long as the filesystem permissions allow.

Oh, one important little piece of information that was surprisingly absent from the sshfs manpage, you can unmount the filesystem as follows:

fusermount -u mountpoint

No comments: