Setting up simple Samba shares 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


Nethence | Pub | Lab | Pbraun | SNE Russia | xhtml