Tero Karvinen - Articles - Downloads - Courses - Contact

Table of Contents

Mount Remote SSH Filesystem with FUSE

Mounting a remote filesystem with sshfs allows you to do anything on the files, just like local files. Because it is an SSH connection, it is secure (encrypted, two-way authenticated), and it works with almost any ssh server.

Mounting with FUSE sshfs mount filesystems on the filesystem level, so unlike Gnome VFS (Places: Connect to Server), all programs can work with the files. FUSE sshfs also works without a graphical user interface.

Procedure described in this article has been tested with Ubuntu 5.10 Breezy Badger. The procedure is likely different on Fedora Core.

© 2005-2007 Tero Karvinen


No special priviledges are needed on ssh server.

Install SSHFS

Add universe and multiverse repositories to /etc/apt/sources.list.

Install sshfs, required programs (fuse-utils libfuse2 and maybe fuse-module) are installed automatically:

$ sudo apt-get install sshfs

Load FUSE kernel module

This should have happened automatically, but it has not (Bug 1680). To work around it

$ sudo modprobe fuse

If you want it to work after reboot, add it to /etc/modules.

Error message that indicates that you forgot to load the module: “fusermount: fuse device not found, try ‘modprobe fuse’ first”

Mount SSH Filesystem

In this example, we mount home directory of user “karvinen” on server “example.com”. Root access is required for mounting. User mounting tool fusermount does not seem to work on Ubuntu 5.10 at the moment (2005-11-23) (Partially described on [[https://launchpad.net/distros/ubuntu/+source/gmailfs/+bug/352|bug 352).

Create mountpoint

$ cd $HOME
$ mkdir sshfs
$ chmod og-rwx sshfs/
$ mkdir sshfs/tkarvine-example

$HOME is normal users home directory, for example “/home/tero/”. The extra directory “sshfs/” prevents other users from reading any sshfs mounted file contents. For actual mountpoints, “user-host” is a good naming convention. Here I used tkarvine-example for account ssh://tkarvine@example.com.

Mount Remote Filesystem

$ sudo sshfs karte@myy.helia.fi: sshfs/karte-myy/ -o allow_other
karte@myy.helia.fi's password:
$ ls sshfs/karte-myy/ |head -2

If you saw the contents of your remote home directory with ls, well done, you have mounted an ssh filesystem remotely.


The procedure above works. However, it would be practical if users could mount directories and I got this working later, after writing the procedure above.

It is also possible to mount as a user. In the following, root allows user “tero” to mount fuse filesystems.

$ sudo gpasswd -a tero fuse
$ mkdir testmount/
$ sshfs tkarvine@example.com: testmount/
$ ls -1 testmount
$ fusermount -u testmount/


Couldn't find package sshfs

‘sudo apt-get install’ says “E: Couldn’t find package sshfs”. Enable universe and multiverse in /etc/apt/sources or use the GUI tool System: Administration: Update Manager to add them.

fuse: failed to exec fusermount: Permission denied

You are not member of “fuse” group.

Add yourself to fuse group:

$ sudo gpasswd -a $LOGNAME fuse
Adding user tero to group fuse

Log out and back so that shell knows about your new groups. Optionally check that “fuse” is mentioned in the list printed by ‘groups’. If ‘sshfs server: mountpoint’ does not give the same error message, group problem is solved.

Fuse device not found

“fusermount: fuse device not found, try ‘modprobe fuse’ first”. Also many other, more obscure error messages if you try to use FUSE without loading the module. Not loading the module automatically is a bug.

$ sudo modprobe fuse

fusermount: old style mounting not supported

‘$ fusermount tkarvine@example.com: tkarvine-example/’ “fusermount: old style mounting not supported”. Use ‘sudo sshfs’ as described above. ‘fusermount’ and ‘mount -t sshfs’ don’t seem to work at the moment.

mount: unknown filesystem type 'sshfs'

‘$ sudo mount -t sshfs foo bar’ “mount: unknown filesystem type ‘sshfs’“. Use ‘sudo sshfs’ as described above. ‘fusermount’ and ‘mount -t sshfs’ don’t seem to work at the moment.

No write permisson, files owned by unkown user

By default, files are owned by uid and gid on remote server. Most likely they are different in two systems. ‘ls -l’ shows weird user and group as file owner. They are either wrong names or just numbers.

Umount your sshfs mounted directory if needed

$ sudo umount tkarvine-example

Find out your numeric user id

$ id
uid=1000(tero) gid=1000(tero)

Specify local user and group id.

$ sshfs tkarvine@example.com: tkarvine-example/ -o idmap=user -o uid=1000 -o gid=1000

Now file owners are correct

$ ls -l tkarvine-example/
drwxr-xr-x 1 tee tee      4096 2007-04-13 12:28 world-domination
-rw-r--r-- 1 tee tee      8994 2006-09-12 15:21 How to get rich by drinkign tea.txt

Saving works now.

See also “-o allow_other”.


FUSE, Filesystem in Userspace http://fuse.sourceforge.net/

SSHFS, SSH Filesystem http://fuse.sourceforge.net/sshfs.html

[Fuse sshfs performance] and reliability already seem far far better than the built in GNOME way. [..] [Fuse is] already in Ubuntu (don’t forget to add yourself to the fuse group, oh, and read the manpage). http://www.whiprush.org/2005/10/fuse.html

fusermount requires the fuse kernel module to be loaded, which they can’t do. https://launchpad.net/distros/ubuntu/+source/fuse/+bug/1860

Storing files off-site with gmail http://www.debian-administration.org/articles/198

Please check and see if gmailfs version 0.4-1ubuntu1 solves your issue. https://launchpad.net/distros/ubuntu/+source/gmailfs/+bug/352

[bug report has been submitted] http://ubuntuforums.org/showthread.php?t=24386



Jones 2006: Mounting a Remote Filesystem with sshfs. “[-o idmap=user -o allow_other -o uid=LOCALUID -o gid=LOCALGROUP] will not only mount the remote share, but will resolve any user id mismatches with the ones you specify with the uid and gid options.” http://www.oreillynet.com/onlamp/blog/2006/11/mounting_a_remote_filesystem_w.html


FUSE sshfs works well enough for advanced users, but is still far from production quality. The ability to install it using apt-get makes sshfs a lot easier to use than it’s predecessor, LUFS (Linux Userland Filesystem). Mounting a filesystem in FUSE is superior to Gnome VFS. In the near future, FUSE will likely work very transparently and many other virtual filesystems become obsolete.

Last modified: 2007-08-22. Permanent url: http://www.iki.fi/karvinen/mount_sshfs.html

Tero Karvinen www.iki.fi/karvinen - Top - Validate HTML - Validate CSS