samba setup on ubuntu
app samba files: /etc/samba/smb.conf sample sbm.conf in private bin
# install samba
sudo apt install sambaload changes
sudo service smbd restartallow samba traffic ufw
sudo ufw allow sambaSecurity
Disable nmbd
in /etc/samba/smb.conf disable netbios = yes smb ports = 445
sudo systemctl stop nmbd.service
sudo systemctl disable nmbd.serviceServer
Samba directory
create directory for samba suers and give permission to sambashare
sudo mkdir /samba
sudo chown :sambashare /samba/Add new users
sudo mkdir /samba/username
sudo adduser --home=/samba/username --no-create-home --shell=/user/sbin/nologin --gecos "" --ingroup sambashare username
sudo chown username:sambashare /samba/username
sudo chmod u=rwx,g=rwxs,o= /samba/wbe
# add user to samba password database(without enabling them)
sudo smbpasswd -a username
# enable user
sudo smbpasswd -e usernameCreate a share
[ShareName] comment = Sahre Descriptio path = /path/to/share/on/server valid users = @sambashare create mask = 0660 directory mask = 2770
@sambashare will allow allow all users of sambashare group create mask will give read write permissions to owner and all members of group directory mask will allow all users to create new directories NOTE: these won’t take effect in certain situation such as an ntfs drive attached to my main linux machine the permissions will not be enforced and the ntfs will take priority ???
Clients
sudo apt install smbclientAuto mount share
need cifs-utils,
sudo apt install cifs-utils1 - store credentials in /etc/samba/credentials 2 - make credentials owned by root and read only by root
sudo touch /etc/samba/credentials
sudo chown root.root /etc/samba/credentials && sudo chmod 400 /etc/samba/credentialsedit /etc/fstab to mount sambashares
echo "/sambaServer/shareName /local/path cifs credentials=/etc/samba/credentials,uid=1000,gid=1000,file_mode=0700,dir_mode=0700" >| /etc/fstab
ex: //wannabeengineer/media /media/samba cifs credentials=/etc/samba/credentials,uid=1000,gid=1000,file_mode=0700,dir_mode=0700 0 0
NOTE: fstab must be reloaded for these changes to take affect so if experimenting with fstab and don’t wanna keep rebooting reload daemon to test changes
systemctl daemon-reloaddebugging: mount: /media/mnttest: mount point does not exist. , first create the mountpoint
sudo mkdir /media/mnttestmount: /media/mnttest: mount(2) system call failed: No route to host. install cifs-utils Auto mount share