sshfs: easy to access remote ssh locations

September 14th, 2007

If you're a heavy ssh user, you already know about scp and rsync+ssh, but even that gets tedious when you're using the same remote location a lot.

A solution to this is KDE's fish:// kioslave, which lets you browse the remote path in konqueror much like you do any other. The drawback is that it's not an actual filesystem, so if you open a video, you'll have to wait before konqueror copies the whole file to a temporary local path before it will open it. (The same goes for smb:// samba shares, and probably all kioslaves.)

I've been using fish:// a lot, but lately it's become very flaky on me, and I don't know why, because the terse error messages don't explain anything. But I also miss how it's less convenient than nfs, which *is* a real filesystem (albeit one that is a pita to configure properly).

But there is another option. (Oh who am I kidding? This is linux, there are probably hundreds of options. ) If you have a remote location you need to access a lot, you could try sshfs. As the name implies, the protocol is still ssh (so the traffic is encrypted), but the interface is that of a filesystem. And it's based on fuse (the user level filesystem layer), so no messing with the kernel necessary.

Here's what you do

emerge sshfs-fuse
echo "fuse" >> /etc/modules.autoload.d/kernel-2.6
modprobe fuse

That should make sure the fuse module is loaded on boot. Now to mount and unmount a remote path:

sshfs host:/path /mount/point
fusermount -u /mount/point

Or, to make it even easier.. save this in /usr/local/bin.

MOUNT_POINT=/mount/point
HOST=host
MOUNT_PATH=/path/on/host

if [ ! -d $MOUNT_POINT ]; then
	echo "mount point $MOUNT_POINT missing"; exit 1
fi

if mount | grep $MOUNT_POINT; then
	echo "umounting..."
	fusermount -u $MOUNT_POINT
else
	echo "mounting..."
	sshfs -C -o transform_symlinks -o Cipher="blowfish" $HOST:$MOUNT_PATH $MOUNT_POINT
fi

:: random entries in this category ::

2 Responses to "sshfs: easy to access remote ssh locations"

  1. Necoro says:

    Do one really need your script? - You can also just add your sshfs mountpoint to fstab
    Is_it_possible_to_mount_a_fuse_filesystem_from_fstabx3f

  2. numerodix says:

    True enough, but given the fact that ssh is used often across internet links and the connectivity and availability of such locations tends to not be permanent (for instance from my laptop), I think I would expect to have to mount it manually anyway. In which case it's pretty much the same amount of typing.