Samba
Install Samba
sudo apt update
sudo apt install samba -y
Create User
To create a new user use the following command:
sudo useradd -M -s /sbin/nologin exampleuser
The useradd
options have the following meanings:
-M
-do not create the user’s home directory.-s /usr/sbin/nologin
- disable shell access for this user.
Add the user account to the Samba database by setting the user password:
sudo smbpasswd -a exampleuser
example-password
You will be prompted to enter and confirm the user password.
New SMB password:
Retype new SMB password:
Added user exampleuser.
Once the password is set, enable the Samba account:
smbpasswd -e exampleuser
Add user to group
sudo usermod -aG sambashare exampleuser
Samba Config
Before you start editing smb.conf you should make a copy
sudo cp /etc/samba/smb.conf /etc/samba/samba.conf.copy
in smb.conf add the following
[global]
server string = Document Server
vfs objects = fruit streams_xattr
workgroup = HOME
security = user
map to guest = never
name resolve order = bcast host
log file = /var/log/samba/log.%m
max log size = 100
include = /etc/samba/shares.conf
access based share enum = yes
Create a file called shares.conf
[Files]
comment = Documents Server
path = /path/to/share
force user = exampleuser
force group = sambashare
create mask = 770
force create mode = 770
directory mask = 770
force directory mode = 770
writeable = yes
[Other]
comment = Other Share
etc, etc
Once done, restart the Samba services with:
sudo systemctl restart smbd
sudo systemctl status smbd