samba

install

pkg install samba42
sysrc samba_server_enable="YES"

config

/usr/local/etc/smb4.conf

[global]
workgroup = WORKGROUP
server string = CSNA Server
netbios name = csna
wins support = Yes
security = user
passdb backend = tdbsam

[public]
path = /home/public
writable  = yes
browsable = yes
read only = no
guest ok = yes
create mask = 0644
directory mask = 0755
hosts allow = 140.116.0.0/255.255.0.0

[homes]
path = /home/%U
writable  = yes
browsable = yes
read only = no
guest ok = no
create mask = 0644
directory mask = 0755
hosts allow = 140.116.0.0/255.255.0.0

public share

user has all permission on his/her own file, but can not delete others.

mkdir /home/public
chmod 3777 /home/public

start service

service samba_server start

add samba user account

smbpasswd -a CSNA2016

mount

sudo mount -t cifs -o vers=3.0,username=${USER},password=${PASSWORD},uid=$(id -u),gid=$(id -g) //server-address/folder /mount/path/on/ubuntu
sudo mount -t cifs -o vers=3.0,username=${USER},password=${PASSWORD},uid=$(id -u),gid=$(id -g),forceuid,forcegid, //server-address/folder /mount/path/on/ubuntu

List shares

smbclient -L ip_of_net_interface -U your_user_name