SMB File Sharing
SMB File Sharing
Samba is an Open Source Project and uses the Common Internet File System ( CIFS ).
It allows us to share files or directories to different Operating Systems ( Windows & Linux ).
Main Configuration File “ /etc/samba/[Link] “.
Client will mount the Samba Share using the “cifs-utils “ and “ samba-client “ Packages.
Samba uses nmb service for NetBIOS Name or Naming Service.
We can use # smbpasswd –a Command to create password for samba username.
We can connect to samba from the client using # smbclient –L Command.
It listens in tcp ports “ 139 & 445 “.
We can use # smbstatus to show the information about the samba server.
Finally we use # testparm to check the parameters of the [Link] config file.
Configuring SMB Server and Client
Install and Activate Samba on Server:
# yum install samba –y
# systemctl enable smb nmb && systemctl start smb nmb
Firewall rule for Samba:
# firewall-cmd –permanent –add-service=samba
# firewall-cmd –reload
Create Samba User:
# useradd smbuser –s /sbin/nologin
# smbpasswd –a smbuser
Create your share on the Configuration file /etc/samba/[Link] and you can
allow a specific host in the Global Options then you can # testparm to check the
configuration.
On the Samba Client:
Install the Related Packages:
# yum install cifs-utils samba-client –y
Add firewall rule:
# firewall-cmd –permanent –add-service=samba-client
# firewall-cmd –reload
Brows the Samba Share on the Server:
# smbclient –L [Link] –U smbuser
Mount the samba share:
# mount //[Link]/samba-share /mnt –o username=smbuser
Or we can mount it on the /etc/fstab file as the below:
# //[Link]/samba-share /mnt cifs username=smbuser,password=password 0 0
Selinux Settings
We have /samba-share Exported Directory by Samba Server so we can adjust the
selinux as the following:
# semanage fcontext –a –t samba_share_t “/samba-share(/.*)?”
# restorecon –Rv /samba-share
And for the Selinux Boolean settings we can do the following:
# setsebool –P samba_export_all_ro on ##if you need it read only.
# setsebool –P samba_export_all_rw on ##if you need it read and write.