Wednesday, February 27, 2019

Samba share different user privilegeds

install samba
=========
sudo apt install samba


add user
=======
Samba has its own user management system.
However, any user existing on the samba user list must also exist within /etc/passwd file.

sudo adduser --no-create-home --disabled-password --shell /usr/sbin/nologin --ingroup sambashare a_user_name

--in-group sambashare :
This adds the user to the sambashare group,
giving them read and write access to their own shares and to the common share.


Samba keeps its own database of users and passwords,
which it uses to authenticate logins.
In order to log in, all users must be added to the Samba server and enabled.

-a : This adds the user to the Samba server without enabling them.
-e : enables the user.

smbpasswd -a user_name
smbpasswd -e user_name


configuration
==========
sudo vi /etc/samba/smb.conf

[global]
    workgroup = WORKGROUP
    server string = Server %v
    disable netbios = Yes
    security = user
    map to guest = bad user
    name resolve order = bcast host
    dns proxy = no
    bind interfaces only = yes
    log file = /var/log/samba/smb.log
    max log size = 10000

[ShareSpace]
    path = /ShareSpace
    guest ok = yes
    write list = samba_user_1 samba_user_2
    force directory mode = 2770
    force create mode = 0660
    force user = unix_username

[HiddenShare]
    path = /HiddenShare
    browseable = no
    read list = samba_user_1
    write list = samba_user_2
    force directory mode = 2770
    force create mode = 0660
    force user = unix_username


testparm

sudo systemctl restart smbd.service



NetBIOS functions are not needed in a standalone server.
======================================
sudo systemctl stop nmbd.service
sudo systemctl disable nmbd.service



File permission
===========
Samba doesn't override the Linux file permissions.
 If the user doesn't have permission to write to the directory from a shell account,
they can't do it through Samba regardless of the configuration.


Windows
=======
The network folder specified is currently mapped using a different user name and password.
To connect using a different user name and password,
first disconnect any existing mappings to this network share.


Thanks:
=======
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-samba-share-for-a-small-organization-on-ubuntu-16-04
https://www.linuxquestions.org/questions/linux-general-1/why-can-i-not-write-to-a-samba-share-when-read-write-is-enabled-475630/
https://linuxconfig.org/how-to-configure-samba-server-share-on-debian-9-stretch-linux
https://spalinux.com/2015/08/install-and-configure-file-sharing-server-using-samba-on-centos-7

Note
The useradd, userdel and usermod commands are lowlevel utilities which are there for historical reasons. (Debian)
Ref: https://askubuntu.com/questions/345974/what-is-the-difference-between-adduser-and-useradd

No comments:

Post a Comment