2.9 KiB
obj | website | aliases | |
---|---|---|---|
application | https://www.samba.org |
|
Samba
Samba is an open-source software suite that provides seamless interoperability between Linux/Unix servers and Windows-based clients. It allows file and print services to be shared across a mixed network of Windows, Linux, and macOS systems.
Configuration
You configure samba with the file /etc/samba/smb.conf
Structure:
The smb.conf
file is structured into sections, each containing key-value pairs that define specific configurations. The sections are enclosed in square brackets ([]
). The most commonly used section is [global]
, which contains global settings applying to the entire Samba server. Other sections define individual shares or specific configurations.
Common Sections:
- [global]:
- Contains global configurations applicable to the entire Samba server.
- [sharename]:
- Custom sections for defining specific shares.
Global Options
[global]
# Workgroup
workgroup = WORKGROUP
# User needs to logon before connection
security = user
# Server description
server string = descriptive string
# Set minimum protocol to SMB3
server min protocol = SMB3_00
# Encrypt passwords in connection
encrypt passwords = yes
# ReadWrite Raw
read raw = Yes
write raw = Yes
Share Options
[MyShare]
# Set share to readonly
read only = no
# Filesystem path
path = /my/share
# Users allowed to access this share
valid users = user
# Enable the share to be seen when connecting
browseable = yes
# Enable writing to the share
writeable = yes
# File and Directory permissions for creation.
create mode = 0750
directory mode = 0750
Recycle Bin
To enable a recycle bin on your share, add this to the config:
# Enable recycle bin
vfs object = recycle
# Set recycle bin location
recycle:repository = /my/share/.Trash
# Directory permissions
recycle:directory_mode = 0750
# Keep the directory structure when something is deleted
recycle:keeptree = Yes
recycle:touch = Yes
# Set max file size
recycle:maxsize = 100000000
# Enable versioning
recycle:versions = no
# Exclude files from versioning
recycle:noversions = *.ini | *.dat
# Exclude from recycle bin
recycle:exclude = *.TMP | *.tmp | ~$*.doc
recycle:exclude_dir = tmp | temp | cache
Snapshots
If you want to expose snapshots (for example from ZFS), add this config:
# Enable snapshots
vfs object = shadow_copy2
# Directory which holds the snapshots (relative to share)
shadow:snapdir = .zfs/snapshot
# Snapshot format (date and time)
shadow:format = SNAP_%Y.%m.%d-%H.%M.%S
# Snapshot sorting
shadow:sort = desc
User Authentication
1. User Mapping:
- Samba maps local system users to SMB users. Use the
smbpasswd
command to set passwords for SMB users.