Setting up simple Samba shares

tested on ubuntu/bionic

Preliminary notes

WARNING: 'workgroup' and 'netbios name' must differ.
WARNING: You have some share names that are longer than 12 characters.

Setup

cd /etc/
mv skel skel.dist
mkdir skel
useradd -m USER

apt install samba
cd /etc/samba/
mv smb.conf smb.conf.dist
sed -r '/^(;|#|$)/d' smb.conf.dist > smb.conf
vi /etc/samba/smb.conf

[global]
security = user
workgroup = SOMESHARE
encrypt passwords = yes
load printers = no
;hostname lookups = yes

;deprecated
;syslog = 0

;no symlinks for windows clients
unix extensions = no

;disable buggy feature
;usershare allow guests = yes
usershare path =

;remove printer shares

[USER]
path = /home/USER
valid users = USER
public = no
writable = yes
browsable = yes
printable = no
create mask = 0644
directory mask = 0777

testparm
smbpasswd -a USER

Ready to go

restart and enable,

tail -n0 -F /var/log/* /var/log/samba/*
systemctl restart smbd
systemctl restart nmbd
systemctl enable smbd
systemctl enable nmbd

test remotely,

smbclient -L SERVER_ADDRESS -W SOMESHARE -U USER

Guest account

allowing guest to auth as anonymous without any password what-so-ever,

useradd -M guest
usermod -p '*' guest

mkdir /data
chown -R guest:guest /data
usermod -d /data guest
vi /etc/samba/smb.conf

[global]
guest account = guest

[guest]
path = /data
public = yes
writable = yes
browsable = yes
printable = no
create mask = 0644
directory mask = 0777

testparm
smbpasswd -an guest

GUI mounts

GUI mounts like,

smb://SERVER_ADDRESS/SHARENAME

Server mounts

Server mounts like (mapping to local UID/GID 1000),

mkdir /mnt/USER
touch /mnt/USER/CIFS_NOT_MOUNTED
vi /etc/fstab

//SERVER_ADDRESS/USER /mnt/USER cifs _netdev,user=USER,pass=PASSWORD_HERE,dir_mode=0755,file_mode=0644,uid=1000,gid=1000 0 0

mount -v /mnt/USER

As for anonymous share,

pass=whatever,noperm

TODO. not sure about noperm

Resources

https://www.samba.org/samba/docs/using_samba/ch06.html

https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Standalone_Server

https://ubuntuforums.org/showthread.php?t=2109996

https://access.redhat.com/solutions/448263

https://www.linuxquestions.org/questions/linux-newbie-8/changing-default-workgroup-name-4175622427/

https://fitzcarraldoblog.wordpress.com/2016/10/17/a-correct-method-of-configuring-samba-for-browsing-smb-shares-in-a-home-network/

https://serverfault.com/questions/163954/how-to-set-guest-user-password-on-samba-server

https://www.samba.org/samba/docs/3.5/man-html/mount.cifs.8.html

https://wiki.samba.org/index.php/Mounting_samba_shares_from_a_unix_client

mounting

mounting Samba share with samba-tools https://www.reddit.com/r/linuxadmin/duplicates/etbr0e/mounting_samba_share_with_sambatools/


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun