Ubuntu – SMB shares mix between guest and user-specific – how to config and troubleshoot

permissionssambasmb

I'm a pretty new user to Linux, though I know Windows pretty well.

I've set up a Linux 14.04 box as a file server. Initially I set up three folders and used the GUI interface in the Files app. In Local Network Share I set the share to Allow others to create and delete files in the folder and for Guest access. This worked fine.

Then last night I created a folder and shared it but did not enable Guest access. I also created a Linux system user account that matches the Windows logon, created a group and set it as owner of the folder, and set the ownership of the folder to the group. When I go to access the new user-specific folder I got a username and password prompt as I expected the first time, and I told it to remember the logon information so I don't see that any more. I can access the folder, reading and writing files to it. The problem is now the original three guest-access folders are no longer working properly for the user with the new login. It has browse and read access as well as delete file permissions but I can't modify an existing file nor run an exe. Those guest-access folders are still working as desired from other computers that have no Linux system user logins configured.

It would seem I need to explicitly configure the original three folder shares to be both guest and user. Can someone walk me through how to do this and to troubleshoot it? I'd prefer to use a GUI if possible.

While I've been waiting for some help here I've been trying to better understand how this works together. The Nautilus GUI-based network share config seems to work well for guest access only, but I discovered it doesn't put the shares information into the main /etc/samba/smb.conf file. I searched for other smb.conf files on the box but found none. It is my suspicion that it would be a very bad idea to modify the main smb.conf file and reference the same shares in both but with different settings. Can someone point me to those files and perhaps tell me how to migrate the information to the main smb.conf file?

Best Answer

Well, while I was waiting for someone to answer I kept digging and worked out an answer. I'm posting here for posterity.

It appears the Nautilus GUI-based sharing is only good for unauthenticated folder sharing. Once a person wants to go to user-specific shared folders, whether mixed with other guest-access shared folders or not, one must use the main /etc/samba/smb.conf file.

In order to not duplicate, I recommend first turning off sharing the folder in Nautilus. Then add the share to the main smb.conf file. To open the file with write-priviledge paste the following command into terminal:

sudo gedit /etc/samba/smb.conf

It will ask you for your main Linux login's password then open the file.

Add a section at the bottom of the file for your shares. To keep things neat and tidy I started with a header: #========= Shares ========

Then I built two sections, one labeled:

# public shared folders

and one labeled:

# User-specific folders

Under the public shared folders header I created shares for the various public folders. Here is an example:

[public]

    comment = public folders for documents and downloaded files
    path=/home/murdfs/Documents/public
    browsable = yes
    guest only = yes
    guest ok = yes
    read only = no
    create mask = 0755

A very important entry there, if you are mixing guest-access folders and user-specific folders on one Linux computer, is the guest only = yes option. This makes it so, even if a computer has an account on the Linux box it will access public folders with the guest account. If you don't do this, such computers will create files and folders in the public share that are owned by their login, so others can see them and open them but can't modify and save them. The idea of public folders is everybody has equal, full, access rights to files and folders, so this result is not right.

The user-specific shares config entries are very similar, but of course are missing the guest only option. Here is an example for comparison:

[MurdRcvr2]

    comment = Murdoch's Gem Shop Receiver2 computer's documents backup
    path=/home/murdfs/Documents/MurdRcvr2
    browsable = yes
    guest ok = no
    read only = no
    create mask = 0755

Once you have added the shares save the file. This will release Terminal so you can do the other steps required there.

Set the ownership of the guest-shared folders. I'll use the same example I gave for the config, for continuity:

sudo chown nobody:nogroup /home/murdfs/Documents/public

Set the ownership of the user-specific folder shares. This presumes you've already created the user account, which caused a group of the same name to be automatically created:

sudo chown :murdrcvr2 /home/murdfs/Documents/MurdRcvr2

Create a Samba username and set a password for the user account:

sudo smbpasswd -a murdrcvr2

Restart the SMB service (note this disconnects all other computers connected to existing shares on this Linux box, so all shared files need to be closed first):

sudo service smbd restart

Now you should be able to access guest-access folders from any computer on the network without logging in and only access the user-specific folders after logging in.