MDLog:/sysadmin

The Journal Of A Linux Sysadmin

Mount Remote Folders via SSH

| Comments

This document describes how to install and use sshfs, a FUSE based filesystem that uses SSH to mount remote folders. Since it is based on FUSE (userspace filesystem framework for Linux) your kernel will need to have the fuse module available. FUSE is included in kernel newer than 2.6.14, so I will assume that you will have it already included in your kernel.

Fuse is included in the stock debian etch kernel (2.6.18) but if you install this on a older debian system you could easily use module-assistant to add FUSE support to your kernel:

1
apt-get install kernel-headers-

uname -r

1
2
3
4
 fuse-source module-assistant
module-assistant clean fuse
module-assistant build fuse
module-assistant install fuse

Installing sshfs

The only thing left is to install sshfs. In debian etch this is as simple as:

1
aptitude install sshfs

This will install also the required dependencies: fuse-utils, libfuse2

Now, we should be able to use sshfs, and we can try to mount a remote server’s /data folder with:

1
sshfs 192.168.0.1:/data ~/mnt

(depending how you connect to the remote ssh server, this will ask you for a user or key password, etc.). You will need to have proper permissions. If you require you can also use -o idmap=user to translate the remote ssh user to the local user specified in the command.

Troubleshooting

If you get this error:

1
2
fusermount: failed to open /dev/fuse: No such file or directory
fuse_mount failed.

this means that even if your kernel uses udev to dynamically create devices, in this case it has not done that. The solution for this is to load first the fuse kernel module. This will take care and create the device /dev/fuse:

1
modprobe fuse

This will work until the first reboot, and if you want to make this change permanent you will have to add the fuse module to the automatically loaded module list. For ex. in debian you would add to your /etc/modules a line containing the word “fuse”.

Note: - you can unmount the remote folder using the regular umount command like:

1
2
3
umount ~/mnt
or using fuse:
fusermount -u /mnt

Comments