Samba On Server (Windows File Sharing from Ubuntu)

This configuration is good for simple file shares for small office and home network file sharing.

Required Ports: TCP 139, 445 & UDP 137, 138

Install Samba
sudo apt install samba -y
Verify Installation and Version
smbd --version

Create a backup of original smb configuration
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.original
Edit Samba Configuration
sudo nano /etc/samba/smb.conf

Set Directory and Contents to Public
sudo chmod -R 777 /directory

Create Samba User with Home Directory
sudo useradd -d /home/sambauser -s /sbin/nologin [sambauser]
Create Samba User without Home Directory
sudo useradd -s /sbin/nologin [sambauser]
Set Password For Samba User
sudo smbpasswd -a [sambauser]

To Restart Samba ofter Changes
sudo systemctl restart smbd

Example /etc/samba/smb.conf
[global] workgroup = CAMMHOME security = user guest ok = no server string = Host Server log file = /var/log/samba/log.%m max log size = 1000 logging = file panic action = /usr/share/samba/panic-action %d server role = standalone server obey pam restrictions = no unix password sync = yes passwd program = /usr/bin/passwd %u passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . pam password change = yes map to guest = bad user usershare allow guests = no [nfspublic] path = /nfspublic comment = General Share writable = yes browseable = yes guest ok = no valid users = user1 user2 user3 # The following forces all writes to be 777, # you may wish to use other permissions depending on needs. # 'obey pam restrictions' needs to be set to 'no' to use permission masks create mask = 777 force create mode = 777 security mask = 777 force security mode = 777 directory mask = 777 force directory mode = 777 directory security mask = 777 force directory security mode = 777 # To hide a folder (Ex: lost+found), use veto files veto files = /lost+found [usbstore] path = /usbstore comment = General Share writable = yes browseable = yes guest ok = no valid users = user1 create mask = 777 force create mode = 777 security mask = 777 force security mode = 777 directory mask = 777 force directory mode = 777 directory security mask = 777 force directory security mode = 777 [nfsroot] path = /nfsroot comment = PXE Root writable = no browseable = yes guest ok = no valid users = user1