samba Server
Install and configure secured samba server (SMB3.11) for local user accounts, not virtual domains.
2022-08-06 Raspbian bullseye
Configuration is based upon:
- UNIX User
- user (maps to parallel samba user)
- UNIX group
sambashare
- Chroot directory
- (discouraged; not implemented)
- Home directory
/srv/samba/user
Installation
graham:~ sudo apt update graham:~ sudo apt install samba graham:~ sudo systemctl stop nmbd smbd # stop smbd for updating graham:~ sudo systemctl disable nmbd # disable nmbd - unused- NetBIOS is not used – ensure it is disabled. This eliminates some windoze link-level niceties but they are unsuitable for unbridged remote access, let alone via open internet.
-
Take note of the network interface names,
lo
andeth0
in this case.
/etc/samba/smb.conf
replace all content
[global] server string = Samba %v workgroup = GEDDYAU server role = standalone interfaces = lo eth0 bind interfaces only = yes disable netbios = yes smb ports = 445 name resolve order = host lm announce = no client min protocol = SMB3_11 client signing = mandatory smb encrypt = yes require strong key = yes map to guest = never restrict anonymous = 2 usershare allow guests = no unix extensions = no use sendfile = yes log file = /var/log/samba/smb.log max log size = 10000 log level = 3 passwd:5 auth:5
bind interfaces
- to include only interfaces through which samba traffic is permitted e.g. prevent including unauthorised VPNs.
additional dns hostnames
- add when supporting multiple DNS domains on the one host.
smb ports
- must be 445 – windoze clients have it hardcoded.
name resolve order
&lm announce
- need to avoid exposing our samba services if we use a shared data centre LAN.
client min protocol
- CRITICAL: must be at least 3.11 to force clients to connect at high security level – in particular, prevent old, very unsafe SMB1 clients from becoming security holes (e.g. ransomeware attacks).
restrict anonymous = 2
- means no guests and don't accept any negotiation about it.
unix extension
- disabled because most clients are windoze and it is better to have consistent behaviour by all the clients.
log file
& notsyslog
- because samba is poorly integated with syslogd. samba has many different, explicit log files.
log level
- the example enables some logging overall but detailed logging for login attempts.
- Verify no syntax errors in samba configuration.
- Verify systemd thinks it has started samba services correctly.
- Verify samba services think they have started (with no shares or connections yet).
- Verify that samba thinks it is running okay.
Create public share everyones
graham:~ sudo vi /etc/samba/smb.conf/etc/samba/smb.conf
append lines to end
[everyones] path = /srv/samba/everyones browseable = yes read only = no force create mode = 0660 force directory mode = 2770 valid users = @sambashare @adminteam admin users = @adminteam
-
UNIX group
sambashare
was automatically created by installation. All samba users belong to it. -
We define UNIX group
adminteam
for samba service administrators, and UNIX useradmin
as chief administrator.
- Verify samba services appear healthy (no connections yet).
Create private share freds for new samba user fred
graham:~ sudo vi /etc/samba/smb.conf/etc/samba/smb.conf
append lines to end
[freds] path = /srv/samba/freds browseable = no read only = no force create mode = 0660 force directory mode = 2770 valid users = fred @adminteam admin users = @adminteam
- Verify samba services appear healthy (no connections yet).
Check security level
Have user fred connect to share fred
(see Samba clients). Then:
-
CRITICAL: Verify protocol level used is
SMB3_11
. - CRITICAL: Verify that both encryption and signing are enabled and at least 128 bits.
- Verify user fred is logged in.
- Verify there is a connection to share freds.