Friday, March 23, 2007

Sshfs

Abstract: apt-get install sshfs && sshfs user@machine:/rep /mnt

Sshfs or how to make your life easier


Haven't you already been in the situation of working from a distant computer and be annoyed. You have to use a shell and make what you can with default editors like vi or emacs (no troll here, anyway I only use ed that I think is the best :-). Or worse, you can open a graphical interface, if any, to use more advanced tool and see that it's annoyingly slow.
Another solution is to copy all your stuff locally, work on it (ok you have your tools) and put it back. But you have to always remember where your last modification was done and after a few go and back, you don't remember what to send. Of course rsync is a good solution, but there is better.

Overview
There is a tool that exists for your eyes only: sshfs.
With it you can now both feel at home and at work on your distant files.
But let's see what the command line has to say:
$ ssh far.faraway.com "ls -a ~/devel/"
. .. README projectv1 projectv2
$ mkdir ~/far-devel
$ ls -a far-devel
. ..
$ sshfs far.faraway.com:~/devel ~/far-devel
$ ls -a far-devel
. .. README projectv1 projectv2
Et voila ! Do as you want.

You have understood everything, sshfs makes your distant file look like local ones using an ssh connexion. You just need an account with an ssh access to the machine.

After this you may need to unmount your sshfs, here is the command :
$ fusermount -u ~/far-devel
Installation
That's wonderful you may say, but how can I get it ?

Let's start with a short explanation of its internals. Sshfs is a filesystem based on ssh and thus can only be implemented is userland (which means not in the kernel). But "every" filesystem must be in the kernel. So an API has been created to make it possible: fuse (filesystem in userland). That's why you need to have fuse in your kernel to install sshfs.

Each user has its prefered way to install it:
apt-get install sshfs
tar xvfz && ./configure && make && sudo make install

Note
You can find information on fuse here : http://fuse.sourceforge.net/sshfs.html

There is more than sshfs over fuse, for example, ftpfs is really useful to work on websites that are on shared web hosting.

No comments: