How to access SMB share from any Linux machine without having to match uid/gids?

Red Squirrel

No Lifer
May 24, 2003
69,759
13,362
126
www.betteroff.ca
I HATE the way linux handles file permissions with network shares. You have to match all the user/group IDs across all systems. That is just retarded. It should go by whatever the user/pass was specified when mounting the share. Then the user who mounted the share should be able to get whatever permissions the specified username has. It should not care what the local user is, because credentials were specified. That's more secure than just checking a stupid user/group ID. But I regress.

Is there a way to get around that, for a specific share? I have this VM that is more or less going to be used to dump/get files from various machines. On the server the share is setup to only be accessible from a specific local user, so I want to be able to access the share from anywhere on the network but I want it to require logging in as that user, ex: specifying -o username=abc,password=abc. But I want to be able to do this from ANY local user on the client machine.

Once the share is mounted I then want that user to be able to write to it, even if it's uid/gid don't match.

Is there some kind of flag in the samba share or something I can put to do that? I know I can just make the share guest accessible but I don't want to do that, I simply want to require a specific user/pass to mount it and once it's mounted it is fully writable and all writes are done by the user on the server without caring who the user on the machine is, because he already had to enter a username and password to mount the share.
 

Azuma Hazuki

Golden Member
Jun 18, 2012
1,532
866
131
Something with groups might help here. If you use user/group based security on your share and make everyone on the client machine a member of, say, "mysambagroup" that may do it.
 

Red Squirrel

No Lifer
May 24, 2003
69,759
13,362
126
www.betteroff.ca
Yeah but I don't want to have to do that on every single machine. I need to be able to take a completely random machine, plug it into that network port, boot off a rescue CD or use the existing OS, mount the share (while specifying the credentials), and have access to it.

Edit: Come to think of it, how do I get a share to show up under "network". If I can access it that way through the GUI then I don't have to worry about mounting it or permissions etc, it will prompt for user/pass but then I should get normal access to the files as if I was that user, I think?

I suppose another option too is using SSHFS instead of SMB... At least for when I need to access it from a Linux machine, I can still use SMB for when I need to access from windows. As I will need both. To the same folder.
 
Last edited:

Red Squirrel

No Lifer
May 24, 2003
69,759
13,362
126
www.betteroff.ca
Ok think I figured it out, not QUITE what I wanted but it might work. In GUI, if I do "smb://pcsvc.loc/shared/" in address bar, it prompts for user/pass, then it works and I get write access as that user, instead of it trying to use my local user and failing because the IDs don't match.

Only thing in some situations such as boot CDs I won't have GUI access. Suppose I can just rsync the files though. Basically this is a server to backup user data when I work on or reformat their machines. Images, raw files, etc. So it needs to be easy to access without modifying each machine but still secure enough that a virus infected PC won't have full blown access to a public share or something.

But yeah guess this will do, can use smb:// for when I'm in a GUI such as when I want to access files from my home PC, or I can use rsync when in command line.