Install Samba and Configure
What is Samba?
Samba is open-source software that runs on Unix/Linux based platforms but is able to communicate with other Operating systems like Windows clients a native application. Samba is based on the common client/server protocol of Server Message Block (SMB) and Common Internet File System (CIFS). So Samba is able to provide this service by providing the Common Internet File System (CIFS).
How to setup the samba server
How to Install Samba in Centos
[root@server samba_user]# yum install -y samba samba-commons cups-libs policycoreutils-python samba-client
Add Group for Samba
[root@server samba_user]# groupadd samba_group
Add User for Samba
[root@server samba_user]# useradd samba_user [root@server samba_user]# usermod -G samba_group samba_user [root@server samba_user]# smbpasswd -a samba_user
Change the SELinux security context
[root@server samba_user]# chcon -R -t samba_share_t /samba_user/ [root@server samba_user]# semanage fcontext -a -t samba_share_t /samba_user/ [root@server samba_user]# setsebool -P samba_enable_home_dirs on
Configure Firewall
[root@server samba_user]# firewall-cmd --permanent --add-rich-rule=‘rule family=“ipv4” source address=“192.168.56.0/24” service name=“samba” log prefix=“samba” level=“info” limit value=“1/m” accept’ [root@server samba_user]# firewall-cmd --reload
Edit Samba configuration file to add specific Directory into Samba
Edit /etc/samba/smb.conf file
[root@server samba_user]# cd /etc/samba/
Before Editing Samba configuration File take a backup
[root@server samba_user]# cp -p smb.conf smb.conf.orig [root@server samba_user]# vi /etc/samba/smb.conf [shared_samba] comment = shared-directory path = /home/samba_user public = no valid users = samba_user, @samba_group writable = yes browseable = yes create mask = 0765
Now start and Enable the Samba Server
[root@server samba_user]# systemctl start smb.service [root@server samba_user]# systemctl enable smb.service
Use below command to connect Samba in Ubuntu
smb://192.168.1.16
For Windows
\\192.168.1.16
Terminal command to connect to Samba Server
smbclient -L \192.168.56.102 -U test
Allow the network to connect with Samba Server
[root@server samba_user]# vim /etc/samba/smb.conf interfaces = lo enp0s8 192.168.56.00/24 hosts allow = 127. 192.168.56. workgroup = MYGROUP [root@server samba_user]# vi /etc/services netbios-ns 137/tcp # netbios name service netbios-ns 137/udp # netbios name service netbios-dgm 138/tcp # netbios datagram service netbios-dgm 138/udp # netbios datagram service netbios-ssn 139/tcp # netbios session service netbios-ssn 139/udp # netbios session service [root@server samba_user]# systemctl start smb.service [root@server samba_user]# systemctl start nmb.service [root@server samba_user]# systemctl enable smb.service [root@server samba_user]# systemctl enable nmb.service