Holy freakin' mackeral, I've just discovered SSHFS (pathetic of me, I know), and this thing is awesomely cool! Most of you know that you can mount Samba-shared drives using smbfs. In other words, you enable Samba on a machine, share a directory, and then go to another machine & mount that shared directory via smbfs, which makes it appear as though that remote directory is actually directly connected to your machine. Pretty freaking cool, except that (a) you have to have Samba set up, which can be a PITA, and (b) you can't share drives over the Net. But don't despair - now there's a better way.
Using SSHFS, if you can ssh into machine BAR from machine FOO, you can mount a directory that's located on BAR and then access it on FOO, as though it was directly connected to FOO. It's super easy to do it - much easier than with Samba - and better still, everything is encrypted! To add icing on the cake, you can set things up in fstab to make the whole process more automated, if you so desire. Sweet!
Here's how to do it on K/Ubuntu 5.10, AKA Breezy Badger:
-
Add the following to your /etc/apt/sources.list:
deb http://ca.archive.ubuntu.com/ubuntu breezy multiverse -
Now install sshfs:
sudo apt-get install sshfs
You'll be told that some extra packages will be installed - fuse-utils & libfuse2 - which is fine. -
Once they're installed, fix your permissions so you mount as a normal user:
sudo chmod +x /usr/bin/fusermount -
Make a mount point directory on your machine that will point to the directory you're mounting on the other machine; in my case, I'm mounting a directory named "music" found on my machine named "chaucer":
mkdir ~/music_on_chaucer -
Load the fuse module that enables sshfs to work:
sudo modprobe fuse -
You shouldn't have to do this step again again, if you run this command, which adds the module so that it automatically loads at boot:
sudo echo 'shfs' >> /etc/modules -
Finally, mount the music directory on chaucer to the mount point on your machine; this assumes, of course, that I can SSH into chaucer!
sshfs 192.168.0.10:/media/sdc1 music_on_chaucer/ -
Start listening to the music you can access in ~/music_on_chaucer
A word about that last command. The syntax is:
sshfs [IP|DNS of remote machine]: local_mount_point
In my case, I used the IP address; if you have the proper entry in your /etc/hosts file, or you're doing this over the Net to a machine that's in DNS, use an easy-to-remember name instead of an IP address. If you don't put anything after the colon, you will end up mounting your home direcotory, which may be fine; if you want to mount a specific directory (like I did in my example), put the path after the colon.
To unmount, use this:
fusermount -u ~/music_on_chaucer
OR this:
sudo umount music_on_chaucer
That's it! That is EASY! So freakin' easy! So, to summarize, once you have everything set up, to mount, use
sshfs 192.168.0.10:/media/sdc1 music_on_chaucer/, and to unmount, use fusermount -u
~/music_on_chaucer or sudo umount music_on_chaucer. Awesome!
(Check out all of my posts on SSH and Samba.)








1. I'm looking forward to trying this. Have any clue whether I can use YAST instead of apt-get?
Posted at 6:34AM on Dec 19th 2005 by Matt