You are here Home » Tech » Samba Server Configuration for CentOS 7 (Guide)

Samba Server Configuration for CentOS 7 (Guide)

by Fahad Saleem

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.

Samba server configuration in CentOS 7

In order to make windows client reachable, add the entry of your server IP address in the Run terminal.

“notepad C:\Windows\System32\drivers\etc\hosts”

The example values are as follows.

Samba server configuration in CentOS 7

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.

“vi /etc/samba/smb.conf

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

success

[[email protected] ~]#”

  • Now use the following command.

“firewall-cmd –reload”

  • Now, CentOS sharing should be accessible in Windows. Go to Run and type “\\centos”.

samba centos  4

  • From your Windows PC, just search for the folder and try to create a text file. You will get an error of permission denied.

samba centos 5 Samba server configuration in CentOS 7

  • You can check the permission for the shared folder by using the following command.

“ls –l”

  • To give anonymous users the permission, use the following command.

“cd /samba

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.

Samba server configuration in CentOS 7

  • 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.

“groupadd smbgrp

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.

“cd /samba
chmod -R 0777 secured/
chcon -t samba_share_t secured/”

  • You need to edit the configuration file again.

Samba server configuration in CentOS 7

“vi /etc/samba/smb.conf”

“systemctl restart smb.service

systemctl restart nmb.service “

  • You can check the settings further as follows.

“testparm”

  • On the Windows device, check the folder now with proper credentials.

 

Samba server configuration in CentOS 7

  • You will have to face the issue of permissions in order to give write permission to the user of Samba server.

“cd /samba
chown -R srijan:smbgrp secured/”

  • Finally, Samba user can write in the folder and the configuration is complete.

Samba server configuration in CentOS 7

This article should be useful in applying CentOS Samba configuration for anonymous servers.

You may also like