Sunday, February 1, 2009

SSHFS on Ubuntu Intrepid

SSHFS is a protocol based on ssh that can be used to mount a folder remotely on your local machine. It's a very effective way to treat folders located on remote machines as if they were part of your local machine folder. For instance, you can use the DVD burner on your laptop to burn nice DVD's without having to actually download all those pictures you have on your old home's desktop computer.

In what follows, I will assume you have ssh already installed in both machines (the remote and the local one). Here are the steps I followed to get SSHFS working on my laptop:

1. Install sshfs by running on a terminal the following:

sudo apt-get install sshfs

(some dependencies will also be installed here).

2. Create a local mount directory. You can create this folder wherever you like but make sure that you're the owner of the directory. For instance, I create the folder remote on my media directory and then change the ownership of the folder:

sudo mkdir /media/remote
sudo chown your-username /media/remote

The folder 'remote' will be used to locally mount the remote folder in your computer.

3. Make sure you belong to the group 'fuse'. To do this, go to System->Administration->Users and Groups, and there select 'fuse' and add yourself to this group.


Now you're ready to mount your remote folder. The way we do this is as follows. Say I want to access the folder 'pictures' that is situated in my home-desktop computer whose domain name is desktop-pc. Then, if the full path is /home/myuser/pictures we have to run the following command to mount this folder on my laptop (local machine):

sshfs desktop-pc:/home/myuser/pictures /media/remote

Go to /media/remote and check that all files in the folder picture on desktop-pc are available in your local machine. You can now do whatever you want with this files as if they were a local folder (for instance, you can burn a DVD with all the pictures in this folder).

In case you've set ssh access to your remote machine through a port different from port 22 (say port 23) and/or only to some users (say only to the user called nameuser), you can modify sshfs the same way you'd do it when you run ssh. In my example, this can achieved as follows:

sshfs -p 23 nameuser@desktop-pc:/home/myuser/pictures /media/remote

Finally, once you're done you can unmount this directory by issuing the following command:

fusermount -u /media/remote

Enjoy!

No comments:

Post a Comment