Mount with sshfs and write file permissions

vkats

I try to sshfs mount a remote dir, but the mounted files are not writable. I have run out of ideas or ways to debug this. Is there anything I should check on the remote server?

I am on an Xubuntu 14.04. I mount remote dir of a 14.04 Ubuntu.

local $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:    14.04
Codename:   trusty

I changed the /etc/fuse.conf

local $ sudo cat /etc/fuse.conf
# /etc/fuse.conf - Configuration file for Filesystem in Userspace (FUSE)

# Set the maximum number of FUSE mounts allowed to non-root users.
# The default is 1000.
#mount_max = 1000

# Allow non-root users to specify the allow_other or allow_root mount options.
user_allow_other

And my user is in the fuse group

local $ sudo grep fuse /etc/group
fuse:x:105:MY_LOACL_USERNAME

And I mount the remote dir with (tried with/without combinations of sudo, default_permissions, allow_other):

local $sudo sshfs -o allow_other,default_permissions -o IdentityFile=/path/to/ssh_key  REMOTE_USERNAME@REMOTE_HOST:/remote/dir/path/  /mnt/LOCAL_DIR_NAME/

The REMOTE_USERNAME has write permissions to the dir/files (on the remote server).

I tried the above command without sudo, default_permissions, and in all cases I get:

local $ ls -al /mnt/LOCAL_DIR_NAME/a_file
-rw-rw-r-- 1 699 699 1513 Aug 12 16:08 /mnt/LOCAL_DIR_NAME/a_file
local $ test -w /mnt/LOCAL_DIR_NAME/a_file && echo "Writable" || echo "Not Writable"
Not Writable

Clarification 0

In response to user3188445's comment:

$ whoami
LOCAL_USER
$ cd
$ mkdir test_mnt
$ sshfs -o allow_other,default_permissions -o IdentityFile=/path/to/ssh_key  REMOTE_USERNAME@REMOTE_HOST:/remote/dir/path/ test_mnt/

$ ls test_mnt/
I see the contents of the dir correctly

$ ls -al test_mnt/
total 216
drwxr-xr-x  1 699 699  4096 Aug 12 16:42 .
drwxr----- 58 LOCAL_USER LOCAL_USER  4096 Aug 17 15:46 ..
-rw-r--r--  1 699 699  2557 Jul 30 16:48 sample_file
drwxr-xr-x  1 699 699  4096 Aug 11 17:25 sample_dir


$ touch test_mnt/new_file 
touch: cannot touch ‘test_mnt/new_file’: Permission denied

# extra info: SSH to the remote host and check file permissions
$ ssh REMOTE_USERNAME@REMOTE_HOST
# on remote host
$ ls -al /remote/dir/path/
lrwxrwxrwx 1 root root 18 Jul 30 13:48 /remote/dir/path/ -> /srv/path/path/path/
$ cd /remote/dir/path/
$ ls -al
total 216
drwxr-xr-x 26 REMOTE_USERNAME  REMOTE_USERNAME   4096 Aug 12 13:42 .
drwxr-xr-x  4 root root  4096 Jul 30 14:37 ..
-rw-r--r--  1 REMOTE_USERNAME  REMOTE_USERNAME   2557 Jul 30 13:48 sample_file
drwxr-xr-x  2 REMOTE_USERNAME  REMOTE_USERNAME   4096 Aug 11 14:25 sample_dir
vkats

The question was answered in a linux mailing list; I post a translated answer here for completeness.

Solution

The solution is not to used both the options default_permissions and allow_other (which I didn't try in my original experiments).

Explanation

The problem seems to be quite simple. When you give the option default_permissions in fusermount then fuse's permission control of the fuse mount is handled by the kernel and not by fuse. This means that the REMOTE_USER's uid/gid aren't mapped to the LOCAL_USER (sshfs.c IDMAP_NONE). It works the same way as a simple nfs fs without mapping.

So, it makes sense to prohibit the access, if the uid/gid numbers don't match.

If you have the option allow_other then this dir is writable only by the local user with uid 699, if it exists.

From fuse's man:

'default_permissions'

   By default FUSE doesn't check file access permissions, the
   filesystem is free to implement its access policy or leave it to
   the underlying file access mechanism (e.g. in case of network
   filesystems).  This option enables permission checking, restricting
   access based on file mode.  It is usually useful together with the
   'allow_other' mount option.

'allow_other'

   This option overrides the security measure restricting file access
   to the user mounting the filesystem.  This option is by default only
   allowed to root, but this restriction can be removed with a
   (userspace) configuration option.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Translate permissions with as sshfs remote mount?

From Dev

Mount a file instead of directory using sshfs?

From Dev

Mount cifs Network Drive: write permissions and chown

From Dev

Can't mount NTFS partition with write permissions

From Dev

PHP: file write permissions

From Dev

faster way to mount a remote file system than sshfs?

From Dev

Is it possible to mount a file with different ownership/permissions?

From Dev

SSHFS mount for digital ocean

From Dev

SSHFS mount for digital ocean

From Dev

Write file to documents directory and permissions

From Dev

Write file to documents directory and permissions

From Dev

Mount USB drive with write permissions for everyone or specific user

From Dev

Mount USB drive with write permissions for everyone or specific user

From Dev

Unable to mount hibernated windows 8 drive on mac 10.8 with write permissions

From Dev

No write permissions after shared directory mount from fstab

From Dev

Change write permissions on samba share mount CentOS7

From Java

Mount a SSHFS volume into a Docker instance

From Dev

How to auto mount using sshfs?

From Dev

How to auto mount using sshfs?

From Dev

Is it possible to auto-mount sshfs

From Dev

unmount sshfs from mount point

From Dev

use SSHFS to mount Synology NAS

From Dev

Can sshfs mount the local disks?

From Dev

sshfs mount without compression or encryption

From Dev

How mount a svfs file system with user permissions? (without sudo)

From Dev

CIFS mount - changing permissions on file doesnt take an effect

From Dev

File permissions on NFS mount show up as 'nobody' after upgrading to 14.04

From Dev

Unable to write to SSHFS folder

From Java

IIS AppPoolIdentity and file system write access permissions

Related Related

  1. 1

    Translate permissions with as sshfs remote mount?

  2. 2

    Mount a file instead of directory using sshfs?

  3. 3

    Mount cifs Network Drive: write permissions and chown

  4. 4

    Can't mount NTFS partition with write permissions

  5. 5

    PHP: file write permissions

  6. 6

    faster way to mount a remote file system than sshfs?

  7. 7

    Is it possible to mount a file with different ownership/permissions?

  8. 8

    SSHFS mount for digital ocean

  9. 9

    SSHFS mount for digital ocean

  10. 10

    Write file to documents directory and permissions

  11. 11

    Write file to documents directory and permissions

  12. 12

    Mount USB drive with write permissions for everyone or specific user

  13. 13

    Mount USB drive with write permissions for everyone or specific user

  14. 14

    Unable to mount hibernated windows 8 drive on mac 10.8 with write permissions

  15. 15

    No write permissions after shared directory mount from fstab

  16. 16

    Change write permissions on samba share mount CentOS7

  17. 17

    Mount a SSHFS volume into a Docker instance

  18. 18

    How to auto mount using sshfs?

  19. 19

    How to auto mount using sshfs?

  20. 20

    Is it possible to auto-mount sshfs

  21. 21

    unmount sshfs from mount point

  22. 22

    use SSHFS to mount Synology NAS

  23. 23

    Can sshfs mount the local disks?

  24. 24

    sshfs mount without compression or encryption

  25. 25

    How mount a svfs file system with user permissions? (without sudo)

  26. 26

    CIFS mount - changing permissions on file doesnt take an effect

  27. 27

    File permissions on NFS mount show up as 'nobody' after upgrading to 14.04

  28. 28

    Unable to write to SSHFS folder

  29. 29

    IIS AppPoolIdentity and file system write access permissions

HotTag

Archive