Samba Server Configuration for CentOS 7 (Guide)
Samba offers file and print services for various clients of Microsoft Windows. It can also integrate with a Windows Server domain. This guide offers the procedure for Samba server configuration in CentOS 7 with anonymous and secured Samba servers.
Samba server CentOS7 also allows for interoperability between Linux/Unix servers as well as Windows-based clients. You need to have one Windows machine to check the CentOS 7 server. The Windows machine must lie on the same workgroup. In order to check the value in the Windows machine, you need to run the “net config workstation” command in cmd prompt.
In order to make windows client reachable, add the entry of your server IP address in the Run terminal.
The example values are as follows.
Anonymous Samba Sharing
- You need to install Samba using the following command.
“yum install samba samba-client samba-common”
- The command will install Samba version 4.1.1. For Samba server configuration, edit the file /etc/samba/smb.conf after creating its backup as follows.
“mv /etc/samba/smb.conf /etc/samba/smb.conf.bak”
- Use the entries like this.
mkdir -p /samba/anonymous
systemctl enable smb.service
systemctl enable nmb.service
systemctl restart smb.service
systemctl restart nmb.service”
- Further, to get rid of CentOS 7 firewall-cmd, use the following command.
“firewall-cmd –permanent –zone=public –add-service=samba”
- You should observe the output as follows.
“[[email protected] ~]# firewall-cmd –permanent –zone=public –add-service=samba
[[email protected] ~]#”
- Now use the following command.
- Now, CentOS sharing should be accessible in Windows. Go to Run and type “\\centos”.
- From your Windows PC, just search for the folder and try to create a text file. You will get an error of permission denied.
- You can check the permission for the shared folder by using the following command.
- To give anonymous users the permission, use the following command.
chmod -R 0755 anonymous/
chown -R nobody:nobody anonymous/
ls -l anonymous/”
- Furthermore, we need to allow the selinux for the Samba configuration as shown below.
“chcon -t samba_share_t anonymous/”
- Now the anonymous user can browse and create the folder contents.
- The content can also be cross-checked at server.
“ls -l anonymous/”
Secured Samba Server
- For creating secured Samba Server, you need to create a group and a user for accessing Samba server with proper authentication.
useradd srijan -G smbgrp
“smbpasswd -a srijan”
- Now, create a folder in Samba and assign permissions like this.
“mkdir -p /samba/secured”
- Again, we have to give permission Selinux to view the process.
chmod -R 0777 secured/
chcon -t samba_share_t secured/”
- You need to edit the configuration file again.
“systemctl restart smb.service
systemctl restart nmb.service “
- You can check the settings further as follows.
- On the Windows device, check the folder now with proper credentials.
- You will have to face the issue of permissions in order to give write permission to the user of Samba server.
chown -R srijan:smbgrp secured/”
- Finally, Samba user can write in the folder and the configuration is complete.
This article should be useful in applying CentOS Samba configuration for anonymous servers.