You are not logged in.

#1 2017-08-13 10:10:06

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

sshfs permission and file ownership.

I have a laptop and a desktop pc; both with archlinux using a simlar setup. What I want is to be able to mount the desktop pc in the laptop via sshfs preserving and enforcing permissions. I have tried (as root or via fstab):

sshfs root@192.168.1.10:/ /mnt/pc-fixe -o idmap=file -o uidfile=/mnt/pcfixe_uid_file -o gidfile=/mnt/pcfixe_gid_file -o transform_symlinks -o allow_other -o default_permissions

with  both pcfixe_uid_file and pcfixe_gidfile being:

oesser:1000
root:0

The pc-fixe represent the desktop pc. oesser is my regular user name with uid 1000 (on both machines). This mostly works except the following problem. If I am oesser on the laptop and go to /mnt/pcfixe/home/oesser and try to create a file, it is created as root instead of oesser:

[oesser@pcelitebook /mnt/pc-fixe/home/oesser]$ echo 'hello' > test
[oesser@pcelitebook /mnt/pc-fixe/home/oesser]$ ls -l test
-rw-r--r-- 1 root root 6 Aug 13 12:02 test
[oesser@pcelitebook /mnt/pc-fixe/home/oesser]$ 

This is weird. The kernel is supposed to enforce permissions (I use the -o default_permissions) option. I am not normally allowed to create root owned files as a regular user. I would like the remote filesystem be handled just as a local one with the same defaults and permissions, is it possible? Note that in the documentation, the default_permissions is supposed to enforce the "access permission". I naively believed it included all normal permissions, including file creation. Am I wrong? Is it a bug? is it possible to enforce all permissions via sshfs? It would be normal that file created as oesser belong to oesser even if I used the root account to mount the remote filesystem.

Last edited by olive (2017-08-13 10:13:46)

Offline

#2 2017-08-13 13:31:55

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: sshfs permission and file ownership.

https://wiki.archlinux.org/index.php/SSHFS#Checklist  wrote:

5. Check that the client's target mount point (folder) is owned by the client user. This folder should have the same user ID as defined in SSHFS's mount options.

What does

ls -l /mnt/pc-fixe

show ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2017-08-13 15:40:03

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: sshfs permission and file ownership.

Lone_Wolf wrote:
https://wiki.archlinux.org/index.php/SSHFS#Checklist  wrote:

5. Check that the client's target mount point (folder) is owned by the client user. This folder should have the same user ID as defined in SSHFS's mount options.

What does

ls -l /mnt/pc-fixe

show ?

If unmounted ls -dl /mnt/pc-fixe shows:

drwxr-xr-x 2 root root 4096 Aug 13 11:14 /mnt/pc-fixe//

But let's be clear about what I want. The two machines are configured similarly (same users account and uid, gid). The /mnt/pc-fixe is mounted via the root account; which show the entire file contents of the desktop PC under /mnt/pc-fixe. What I want is that permission on /mnt/pc-fixe are enforced normally: as root I can do what I want; as oesser (my user) I can do what oesser can normally do on the files that reside on the remote machine and if I add another user say usertest; then usertest can do what usertest can do according to the permissions. The default_permissions option should enforce that and does indeed in most cases, as I can't modify a root owned file as oesser. However new files created as oesser are owned by root. Note that the uid are correctly translated in my case and appear correctly under "ls -l".

In fact I do quite understand the default_permissions option. It apparently enforce some permissions but not every one in a way that does not appear to make sense.

Last edited by olive (2017-08-13 15:49:59)

Offline

#4 2017-08-13 17:12:03

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: sshfs permission and file ownership.

Hey Olive, after peeking a few times at the way you do things, their a little different from what I do, though, I get the results you want, but it may not be the way you want it to be!?
If I use sshfs with my 'unix user' I mount the remote fs to a folder actually owned by that user. All files and folders in remote folders & files are accessable by the unix user, though, I cannot edit files owned by root.
Then if I use root to login to sshfs and mount it in /mnt, I can edit an delete all files and folders, though creating files and folders in the 'unix user's' domain, would lead to that files and folders being owned by root.
Is this not how it's supposed to be working?
Oh, and btw.  sshfs unixuser@rem_addr:/ $HOME/mount or sshfs root@rem_addr:/ /mnt/sshfs should be enough then.

Offline

#5 2017-08-13 17:43:40

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: sshfs permission and file ownership.

@qinohe

While this is I end up doing, this is not optimal; because several mount are needed for the different users. I expected to do a single mount as root and have all the file permission enforced. I think I can do that with other network file system like NFS; but apparently not with sshfs. But this is weird that they document a "default_permissions option that do not work properly.

Last edited by olive (2017-08-13 17:43:58)

Offline

#6 2017-08-13 18:15:56

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: sshfs permission and file ownership.

Well It works on the remote host istself, but then you mount the files to a fs system owned by root which is not the same one as the one on your remote host. Their both called 'root' but that's about it, far as I know.

Offline

#7 2017-08-13 21:58:59

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: sshfs permission and file ownership.

Did you try "idmap=user?

Offline

Board footer

Powered by FluxBB