Showing posts with label sshfs. Show all posts
Showing posts with label sshfs. Show all posts

Monday, 18 March 2013

SOLVED: "Permission denied" when mounting sshfs

I've just come across an annoying bug while attempting to mount a directory using sshfs.

sshfs brettg@myserver.net:/home/brettg/test /home/brettg/test
fuse: failed to open /dev/fuse: Permission denied


The normal google search resulted in many, many hits explaining that this is due to the user account not being a member of the 'fuse' group.

Trouble is, my user account is a member of the fuse group:

$ groups
brettg adm cdrom sudo dip plugdev fuse lpadmin sambashare libvirtd


Note: To add your user to the fuse group use this command:

sudo usermod -a -G fuse brettg

The problem is that Mint 14 sets the user permissions on the fuse device incorrectly which results in only the root user being able to mount it.

You can confirm this is the case like this:

$ ls -al /dev/fuse
crw------T 1 root root 10, 229 Mar  9 10:15 /dev/fuse


There are two problems here. The first is that the fuse device is not owned by the fuse group. Fix it like this:

$ sudo chgrp fuse /dev/fuse


The next problem is that the group permissions for the fuse device are set to deny access to everyone. Fix that with:

sudo chmod 660 /dev/fuse


The fuse permissions should now look like this:

$ ls -al /dev/fuse
crw-rw---- 1 root fuse 10, 229 Mar  9 10:15 /dev/fuse


Having done this you should now be able to mount a fuse device (such as sshfs) as a normal user (who belongs to the fuse group of course).

UPDATE
Upon reboot, I noticed that the permissions on the fuse device were partly reset;

$ ls -al /dev/fuse
crw-rw-rwT 1 root root 10, 229 Mar 18 12:03 /dev/fuse



However, this does not appear to have had an adverse effect on my ability to mount. I find this to be somewhat confusing.

Saturday, 26 July 2008

HOWTO: Mounting SSH directories

If you want to mount a directory on a remote PC then here is what you do.

Of course, to mount a folder via ssh the server must be running as a ssh server.

sudo apt-get install openssh-server

It is not necessary, but I strongly recommend that you set up passwordless ssh logins between the server and the client. The linked guide describes setting up SSH keys between two root users, so you do need to ensure that you configure things correctly for whatever pair of users you intend to use here.

From here on, all of the configuration we need to do is on the client.

1. Install SSHFS;

sudo apt-get install sshfs

2. Use the modprobe command to load fuse into the kernel;

sudo modprobe fuse

3. Set up the appropriate users & permissions;

sudo adduser username fuse
sudo chown root:fuse /dev/fuse
sudo chmod +x /bin/fusermount


If you've added yourself to the fuse user group, you need to logout and back in at this point.

To mount the home directory of "user";

sshfs user@host: mountpoint

Eg.

sshfs brett@server: ~/server_home

You can add a path after the colon.

Eg. to mount the "share" directory on the server (ie. /home/brett/share)

sshfs brett@server:/share ~/share

UPDATED: By default, only the user who has mounted the share has access to it. To allow access to root add the following option;

-o allow_root

For all users;

-o allow_other

To mount the share as read only;

-o ro

Eg. to mount the "share" directory on the server as read only and available to all users;

sshfs -o allow_other -o ro brett@server:/share ~/share

And that is all you need to do! Easy Peasy!