Home

Debian/Ubuntu Tips & Tricks

Debuntu.org: .deb packages, Unix/Linux Tutorials and Articles.

sponsors


User login

Poll

Syndicate

Syndicate content


Tips


How To: Mount a remote filesystem using SSH, SSHFS and FUSE

SSH is a protocol to securely connect to a remote host. In previous article we have seen how-to connect to a remote database through a secured tunnel.
It is possible to transfer files using ssh protocol by using the scp command, it would be neat to be able to mount a remote directory through a secure protocol, so this way, all the transferred data will be encrypted.
A combination of FUSE(a userspace filesystem framework) and SSHFS(SSH FileSystem) will do the job. FUSE is a

Here is the case, let's say I have an ssh access on a computer out of my lan network. I would like to be able to easily access those datas without having to use scp nor a specific software to transfert those datas, basically, I would like those datas to be accessible just like if there were on my local computer.
The tools we are going to need are: FUSE and SSHFS. So first of all, install them.

tester@laptop:~$sudo apt-get install sshfs fuse-utils

As we want to be able to mount the filesystem as user tester, we need to add tester to group fuse. Type:

tester@laptop:~$ sudo usermod -G `groups tester | cut -f2 -d':' | tr -s ' ' , | cut -f2- -d,`,fuse tester

This command helps you to get the groups user tester belongs to, we clean the output, translate the ' ' (spaces) to ',' (commas) and add the group fuse at the end.
Note that if your system has the adduser command, you can use the following syntax:

tester@laptop:~$sudo adduser tester fuse

In order to have your user added to the new group, you will have to log out and then log back in

We also need to include the fuse kernel module:

tester@laptop:~$sudo modprobe fuse

In order to include this module at boot time, you need to edit /etc/modules and add fuse to the list.

Now, let's create a directory where we want to mount the file system:

tester@laptop:~$mkdir remotefs

Now it is time to mount the whole thing:

tester@laptop:~$sshfs my-remote-user@my-remote-host:/home/my-remote-user remotefs/

Here you are, you can now access your remote datas as if there were on your local filesystem, awesome :) .

If you want to unmount this filesystem, use:

tester@laptop:~$fusermount -u remotefs/


intergrate sshfs fstab (u)mount with ifup and ifdown systems

I made a support package that integrates sshfs better with the ifup and ifdown network systems, it works with all network managers like gnome-network-manager or the /ect/network/interfaces systems.

I hope you like it, there is also a private repository and a mailinglist see the readme in the root of the svn repoisory, join and help out if you like.

package is also in debian mentors waiting for a sponser:
http://mentors.debian.net/debian/pool/main/p/pct-sshfs-storage/

https://secure.powercraft.nl/svn/packages/trunk/source/pct-sshfs-storage/debian/pct-sshfs-storage_0.1.0-1_all.deb

Source: pct-sshfs-storage
Section: misc
Priority: extra
Maintainer: Jelle de Jong
Build-Depends: debhelper (>= 7)
Standards-Version: 3.8.1
Homepage: https://secure.powercraft.nl/svn/packages/trunk/source/pct-sshfs-storage/

Package: pct-sshfs-storage
Architecture: all
Depends: sudo, sshfs, ifupdown
Description: intergrate sshfs fstab (u)mount with ifup and ifdown systems
This package contains scripts and a configuration system to easily
intergrate your sshfs remote storage system with the standard ifup and
ifdown systems. This will make it possible to disconnect and reconnect
to diffrent networks without freezing your sshfs mounts.
.
Features:
- uses the sshfs entry in /etc/fstab
- supports multiple users, servers, and mount locations
- connect and disconnect sshfs mounts when network goes up/down
- possiblility to automatic make smart symbolic links
- prechecks on mount points and debuging options
- uses bash, mount and umount mainstream processing tools

It worked

Tried another tutorial first, it didn't work. This did. (Don't ask me why!)

Thankyou!!

But what about Dapper.

This worked fine for me in Breezy. I use(ed) it daily in my work. Then I "Upgraded" to Dapper and things got really bad.

sshfs <>:/ <>

gives the error message "fusermount: failed to open /dev/fuse: No such file or directory"

Have I missed something or must I do something different with Dapper? Worked fine on Breezy.

TIA

Bobby

fuse module

You have got to make sure that fuse module is loaded. See on the article how to do this.
Debuntu

You left something out.

You left out the part where you have to log out and back in after adding yourself to a group. I don't know (XYZ)buntu very well, but I'm using Debian, and relogging in, at least in the default configuration, is a requirement to put yourself in a new group.

Besides that, good tutorial. Simple. Clear. Good.

Yeah you are right, logging

Yeah you are right, logging out is required in order to get included in a group.
I've modified the how-to in order to take this into account.
Thanks for your comment.
regards
Debuntu

THANK You!

Another happy non-headbanger, thanks to you, Debubuntu!

This has everything I'd spent hours sifting through myriad webpages for - and all in one page. Ubuntu help is everything Ubuntu's myriad fans say it is.

About fuse kernel module and mounting problem

Why do you need the command "sudo modprobe fuse"? I could mount without running the command. I did not even have fuse in /etc/modules.

But I got this message after telling my password, when I ran the sshfs command:

fusermount: failed to open /dev/fuse: No such file or directory

The sshfs command succeeded after reinstalling fuse-utils. I am using Xubuntu 6.06.

fuse module needs to be loaded, so you got /dev/fuse

Hi Jarno,
modprobe fuse should create the /dev/fuse device (as far as I can recall), this is why if you did not modprobe fuse in the first place, you had the error about not finding /dev/fuse.

Debuntu

Another way to do this using

Another way to do this using a GUI is to use the Gnome volume manager to add the remoate system as a mounted share on the desktop. This can be done using SSH, and appears as a local drive available in Nautilus; moving files is a simple drag and drop.


Hi Josh, Yes, this is a wa

Hi Josh,

Yes, this is a way to do it for people using gnome or kde desktops, but people using light-weight desktop such as fluxbox... might not be able to do so, therefore the command line will be usefull ;)


Apart from that, the Gnome VF

Apart from that, the Gnome VFS and KIO slaves use a completely different mechanism. FUSE is totally transparent and can be used from any application, where the other solutions only work from within applications that support them.