Samba is a free software re-implementation of the SMB/CIFS networking protocol, and was originally developed by Andrew Tridgell. Samba provides file and print services for various Microsoft Windows clients and can integrate with a Microsoft Windows Server domain, either as a Domain Controller (DC) or as a domain member.
Step 1: Installing Samba Server
To install the Samba software, run:
yum update && yum install samba samba-client samba-common
To check the Samba version, run:
smbd -V
Version:-samba 4.6.2
Step 2: Configure Samba Share
Now to configure samba, edit the file /etc/samba/smb.conf. Before making changes, I will make the backup of original file as /etc/samba/smb.conf.bak
cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bak
Now edit the file /etc/samba/smb.conf and add below share in it.
vi /etc/samba/smb.conf
[global] workgroup = WORKGROUP
[01-software] path = /home/software valid users = software guest ok = no writable = yes browsable = yes [02-temp] path = /home/temp valid users = temp software student guest ok = no writable = yes browsable = yes [03-student] path = /home/student valid users = student guest ok = no writable = yes browsable = yes
Save the file and then test it with the testparm utility. If there are any errors, the output of the following command will indicate what you need to fix.
Step 3: Adding Samba Users
Next, you will need to add Samba users. To do so, you will use the smbpasswd command, which interacts with Samba’s internal database.
useradd software smbpasswd -a software useradd temp smbpasswd -a temp useradd student smbpasswd -a student
Step 4: Configuring SELinux and Firewalld
In CentOS 7 Firewall will block the samba access so we have to disable it.The first thing to do is to check the status of SELinux on your system, and you can do this by running the following command:
sestatus
Next, proceed to disabling SELinux on your system, this can be done temporarily or permanently depending on what you want to achieve.
To permanently disable SELinux, use your favorite text editor to open the file /etc/selinux/config as follows:
vi /etc/selinux/config
Then change the directive SELinux=enforcing
to SELinux=disabled.
save and exit the file.
Now we have to disable firewalld, run the following command as root:
systemctl disable firewalld
After that reboot the system.Then check the selinux and firewalld status by using below commands:-
getenforce
systemctl status firewalld
As we have to share the temp samba share with all the users defined then we want to change its permissions by using below command:
chmod -R 0777 /home/temp/
After all the changes done we have to restart Samba, enable the service to start on boot services by using commands:
systemctl enable smb.service systemctl enable nmb.service systemctl restart smb.service systemctl restart nmb.service
Step 5: Mounting the Samba Share in Windows
Click “Start”, then click Computer. You’re now in ‘My Computer/Explorer’.
Right-click Computer, and click “Add a network location”
Then enter the server and share you would like to connect to
\\[servername]\[sharename]