From 498e52c1343ca348f28f189adacadbd24d18ecae Mon Sep 17 00:00:00 2001 From: ducoterra Date: Fri, 6 Feb 2026 20:24:18 -0500 Subject: [PATCH] add samba user creation notes --- active/software_smb/smb.md | 44 ++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/active/software_smb/smb.md b/active/software_smb/smb.md index 8c5e919..35491c6 100644 --- a/active/software_smb/smb.md +++ b/active/software_smb/smb.md @@ -5,6 +5,7 @@ - [Create SMB User](#create-smb-user) - [Create a SMB Share](#create-a-smb-share) - [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 @@ -19,28 +20,32 @@ sudo firewall-cmd --reload ## Create SMB User ```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 ```bash # Create share -mkdir /btrfs/pool0/smb/ducoterra +mkdir /srv/smb/sambauser # 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 -sudo restorecon -R /btrfs/pool0 +sudo restorecon -R /srv ``` Edit /etc/samba/smb.conf ```conf -[ducoterra] +[smb_sambauser] comment = My Share - path = /btrfs/pool0/smb/ducoterra + path = /srv/smb/sambauser writeable = yes browseable = yes public = no @@ -59,8 +64,8 @@ sudo systemctl restart smb ```bash sudo groupadd myfamily -sudo useradd -G myfamily jack -sudo useradd -G myfamily maria +sudo useradd -G myfamily jack +sudo useradd -G myfamily maria sudo smbpasswd -a jack sudo smbpasswd -a maria @@ -94,4 +99,25 @@ Don't forget to restart smb ```bash systemctl restart smb -``` \ No newline at end of file +``` + +## 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 +```