File ownership and permissions for files transferred from Linux to Linux

SandLake

New Member
Joined
Sep 25, 2023
Messages
9
Reaction score
1
Credits
96
I have a ZimaOS system that I can (SSH) log into as UserA/PasswordA and also a Synology NAS that I can log into with the same UserA/PasswordA. They are both set as network drives (set up using UserA/PasswordA) on a Windows PC (I don't think the windows login is relevant but it is not UserA/PasswordA).

There are files on the Synology NAS which have the owner:group UserA:GroupA which are in directories which have the owner:group UserA:GroupA

On the Windows PC when I drag and drop the files from the Synology NAS to the ZimaOS system the files subsequently have the user:group root:root and they are in directories which have the user:group root:root and the files have changed from rwxrwxrwx to rwxr--r--

What do I need to do to have these files/directories have the owner:group UserA/GroupA with any intervention?

So far I have found out about umask which I believe I can use to sort out the default file permissions.

I think but I haven't verified it that rsync does transfer the files in the way that I want.
 


How you tried something like this?

Code:
rsync -avz --chown=UserA:GroupA /path/to/source/ UserA@ZimaOS:/path/to/destination/

Code:
umask 0022

Are you using Samba? You can also try ths.

Code:
[global]
preserve case = yes
short preserve case = yes
 
Thanks but my problem is when I drag and drop files onto the destination server.

rsync seems to work fine and I would like to be able to drag and drop too or at least understand how to.
 
In Linux, it generally depends on "who" you are doing something as.

It doesn't matter who originally owned the files. When you drag and drop it will always change the permissions/ownership
to whoever is doing this. I really don't know of any way around this.
 
I'm obviously wrong but I think the the only "user" the destination can see is the user that logs into the network share from windows which is UserA so that should be the "who" that is doing this - but the files and directories still end up being owned by root.
Somehow root must be the one doing this!
 
My bad, I assumed the drag and drop was on a Linux system.
The thread title said from Linux to Linux.

you can map a Windows user to a Linux user in Samba by creating a special file on the Samba server.

Create a file called /etc/samba/smbusers.
Add entries in the format linux_user = windows_user, where linux_user is the Linux username and windows_user is the Windows username.
  • Example:
linuxuser = windowsuser

Open the Samba configuration file, usually located at /etc/samba/smb.conf.
Add the following line in the [global] section:username map = /etc/samba/smbusers
Restart the Samba service to apply the changes. You can do this with the following command:sudo systemctl restart smbd

You have to have a way to "map" the users.. Otherwise, how would Linux or Windows know about the other user?
The only way I know of to do this, is with Samba. It works best if the usernames match exactly, but they don't have to.
If the Linux system doesn't have a user "mapped" to the Windows user, then you are right, now it's root.
 
Last edited:
ZimaOS (or CasaOS) have a BIG banner in smb.conf stating DO NOT MODIFY

# IMPORTANT: CasaOS will not provide technical support for any issues
# caused by unauthorized modification to the configuration.

Not entirely sure what 'unauthorized modification' means, it's a config file and it's on MY server!
 
Oh, you can modify it. They just won't provide support if you do so in a way they've not documented and approved. If you change it, you're on your own.

That makes sense for some things.
 


Members online


Top