add samba user creation notes

This commit is contained in:
2026-02-06 20:24:18 -05:00
parent dd11ef60cb
commit 498e52c134

View File

@@ -5,6 +5,7 @@
- [Create SMB User](#create-smb-user) - [Create SMB User](#create-smb-user)
- [Create a SMB Share](#create-a-smb-share) - [Create a SMB Share](#create-a-smb-share)
- [Create a SMB Share with Many Users](#create-a-smb-share-with-many-users) - [Create a SMB Share with Many Users](#create-a-smb-share-with-many-users)
- [Mount SMB Share at Boot](#mount-smb-share-at-boot)
## Install SMB ## Install SMB
@@ -19,28 +20,32 @@ sudo firewall-cmd --reload
## Create SMB User ## Create SMB User
```bash ```bash
sudo smbpasswd -a ducoterra # Add a linux user
sudo adduser --no-create-home --disabled-password --disabled-login sambauser
# Add the samba user with password
sudo smbpasswd -a sambauser
``` ```
## Create a SMB Share ## Create a SMB Share
```bash ```bash
# Create share # Create share
mkdir /btrfs/pool0/smb/ducoterra mkdir /srv/smb/sambauser
# Set proper selinux labels for samba # Set proper selinux labels for samba
sudo semanage fcontext --add --type "samba_share_t" "/btrfs/pool0/smb/ducoterra(/.*)?" sudo semanage fcontext --add --type "samba_share_t" "/srv/smb(/.*)?"
# Run restorecon at the root of the btrfs subvolume # Run restorecon at the root of the btrfs subvolume
sudo restorecon -R /btrfs/pool0 sudo restorecon -R /srv
``` ```
Edit /etc/samba/smb.conf Edit /etc/samba/smb.conf
```conf ```conf
[ducoterra] [smb_sambauser]
comment = My Share comment = My Share
path = /btrfs/pool0/smb/ducoterra path = /srv/smb/sambauser
writeable = yes writeable = yes
browseable = yes browseable = yes
public = no public = no
@@ -59,8 +64,8 @@ sudo systemctl restart smb
```bash ```bash
sudo groupadd myfamily sudo groupadd myfamily
sudo useradd -G myfamily jack sudo useradd -G myfamily jack
sudo useradd -G myfamily maria sudo useradd -G myfamily maria
sudo smbpasswd -a jack sudo smbpasswd -a jack
sudo smbpasswd -a maria sudo smbpasswd -a maria
@@ -95,3 +100,24 @@ Don't forget to restart smb
```bash ```bash
systemctl restart smb systemctl restart smb
``` ```
## Mount SMB Share at Boot
Make sure your install cifs-utils: `dnf install cifs-utils`
Create a password file at `/etc/samba/credentials` with contents like
```text
username=USERNAME
password=PASSWORD
```
Then edit `/etc/fstab` to mount the share
```conf
# With login
//server_name/share_name /local_mount_point cifs _netdev,nofail,uid=1001,gid=1001,credentials=/etc/samba/credentials 0 0
# As guest
//server_name/share_name /local_mount_point cifs _netdev,nofail,guest 0 0
```