Commit 9a8f77
2026-08-06 00:27:04 Niklas Polke: Create SAMBA| /dev/null .. linux/samba.md | |
| @@ 0,0 1,95 @@ | |
| + | # SAMBA |
| + | |
| + | ## Preparation |
| + | |
| + | 1. Create group for backups |
| + | ```bash |
| + | sudo groupadd backupusers |
| + | ``` |
| + | - create new group `backupusers` |
| + | |
| + | |
| + | 2. Create user for samba |
| + | ```bash |
| + | sudo adduser --disabled-login --no-create-home --gecos "" smbbackup |
| + | sudo usermod -aG backupusers smbbackup |
| + | |
| + | ``` |
| + | - --disabled-login - no system login |
| + | - --no-create-home - no user home directory |
| + | - --gecos "" - no interactive questions for name and so on |
| + | - with `usermod`: add user `$USER` to group `backupusers` |
| + | |
| + | 3. Prepare directory to use with samba |
| + | ```bash |
| + | sudo chown root:smbbackup /srv/ssd/backups |
| + | sudo chmod 2770 /srv/ssd/backups |
| + | ``` |
| + | |
| + | 4. Install samba |
| + | ```bash |
| + | sudo apt install samba samba-common-bin smbclient cifs-utils |
| + | systemctl status smbd --no-pager |
| + | ``` |
| + | - last one for checking status of smbd (active?) |
| + | |
| + | 5. Registrate user for samba |
| + | ```bash |
| + | sudo smbpasswd -a smbbackup |
| + | sudo smbpasswd -e smbbackup |
| + | ``` |
| + | - first one registrates smbbackup with a chosen password as user in samba |
| + | - second one enables user smbbackup |
| + | |
| + | 6. Change samba configuration |
| + | ```bash |
| + | sudo cp /etc/samba/smb.conf "/etc/samba/smb.conf.backup-$(date +%F-%H%M%S)" |
| + | sudo nano /etc/samba/smb.conf |
| + | ``` |
| + | add at the end |
| + | ``` |
| + | [Backups] |
| + | comment = Backups auf der externen SSD |
| + | path = /srv/ssd/Backups |
| + | |
| + | browseable = yes |
| + | read only = no |
| + | guest ok = no |
| + | |
| + | valid users = smbbackup |
| + | force group = backupusers |
| + | |
| + | create mask = 0660 |
| + | force create mode = 0660 |
| + | directory mask = 2770 |
| + | force directory mode = 2770 |
| + | ``` |
| + | |
| + | 7. Restart samba |
| + | ```bash |
| + | sudo testparm -s |
| + | sudo systemctl restart smbd |
| + | ``` |
| + | - check configuration and then restart |
| + | |
| + | 8. Checks |
| + | ```bash= |
| + | sudo systemctl status smbd --no-pager |
| + | smbclient -L localhost -U smbbackup |
| + | smbclient //localhost/Backups -U smbbackup |
| + | ``` |
| + | 1: check service active and enabled |
| + | 2: check Shares of samba |
| + | 3: connect to shell of samba and test `mkdir test` |
| + | |
| + | 9. Prepare connection to network |
| + | ```bash= |
| + | sudo ufw app list |
| + | sudo ufw app info Samba |
| + | sudo ufw allow in on <eth0> from <192.168.2.0/24> to any app Samba |
| + | sudo ufw status |
| + | ``` |
| + | 1: all apps ufw knows |
| + | 2: ufw info about Samba app (ports) |
| + | 3: open ports for LAN in network to Samba |
| + | 4: show changed ufw rules |
