Working on a remote box with sshfs

written by paul on September 5th, 2007 @ 10:41 PM

I needed to edit numerous files today on a remote linux box. Normally, I would ssh in and use vi. However, I had to edit ruby/rhtml files and I wanted a familiar environment (in this case, TextMate).

I briefly looked at mounting the remote filesystem over NFS. However, NFS was not set up and I did not have the permissions to do it myself.

I googled around for a bit and discovered sshfs. This tool let me mount a remote file system with nothing more than ssh access. It is even included in MacPorts.

All I had to do was run:

% sudo port install sshfs

to install it, and then:

% sshfs user@host:/path/to/remote /tmp/remotefs

to mount the remote path under /tmp/remotefs on the local box. Now, I can open TextMate and edit the files as if they were local:

% cd /tmp/remotefs
% mate .

sshfs uses FUSE to set up a filesystem in user space. I do not need root access to mount the filesystem, and once it is mounted, it acts just like any other filesystem.

Here is the entry from running ‘df’:

sshfs#user@host:/path/to/remote
                       7812500         0   7812500   0% /tmp/remotefs

I can now unmount the drive with (unless it is a mac, for some reason):

% fusermount -u /tmp/remotefs

or the more familiar:

% sudo umount /tmp/remotefs

Note that using fusermount does not require root but using umount does.

Comments

  • Erk on 07 Sep 16:04

    Since you're all about the mac these days. You should know about the less command liney way to do this: http://www.sccs.swarthmore.edu/users/08/mgorbach/MacFusionWeb/ It's a pretty slick add on to Fuse. I use it all the time at work. Erk

Post a comment

Options:

Size

Colors