samba_server

As you may know, Samba is an open source, and free software suite that provides file and print services to the SMB/CIFS clients. It allows us to share files, folders, and printers between Linux server and Windows clients

This Tutorial describes you the Step by Step procedure to install and configure the SAMBA server and client on Linux and windows (RHEL7/CentOS7/Window 7/8.1/10).

  • What is Samba?

Samba provides a stable and highly compatible file and print sharing service that allows a Linux node to act as a client, a member server, or even a Primary Domain Controller (PDC) or a member of an Active Directory (AD) service on Microsoft-based networks. Samba interacts with Microsoft’s CIFS built on the Server Message Block (SMB) protocol.

Samba details
Package : samba*
Port no : 137,138,139
Script : /etc/init.d/smb
Service name : smb
Daemon : smbd
Configuration file : /etc/samba/smb.conf

Use the following instructions to install and configure the SAMBA Server and Client on Linux (Centos7/RHEL7).

Lab Setup:
[root@server ~]# hostnamectl set-hostname server.example.com

[root@server ~]# systemctl enable network

[root@server ~]# systemctl stop firewalld

[root@server ~]# systemctl disable firewalld

Selinux are disabled

[root@server ~]# vim /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing – SELinux security policy is enforced.

# permissive – SELinux prints warnings instead of enforcing.

# disabled – No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of three two values:

# targeted – Targeted processes are protected,

# minimum – Modification of targeted policy. Only selected processes are protected.

# mls – Multi Level Security protection.

SELINUXTYPE=targeted

[root@server ~]# vim /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.10 server.example.com server

192.168.1.20 client.example.com client

Server end configuration

[root@server ~]# yum install samba samba-client samba-common -y

Configure the Samba server
Samba server main configuration file name is smb.conf which is located in /etc/samba/. It has many directives which can be used for each purpose.

Now configure samba edit the file /etc/samba/smb.conf

[root@server ~]# mv /etc/samba/smb.conf /etc/samba/smb.conf.bkp

[root@server ~]# vi /etc/samba/smb.conf

and paste following line:

[global]

workgroup = WORKGROUP

server string = Samba Server %v

netbios name = centos

security = user

map to guest = bad user

dns proxy = no

#============================ Share Definitions ===============================

[SAMBASHARE]

path = /samba/

browsable =yes

writable = yes

guest ok = yes

read only = no

Test the Samba server configuration

We can test the Samba server configuration syntax errors using the command ‘testparm’.

[root@server samba]# testparm

Load smb config files from /etc/samba/smb.conf

rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)

Processing section “[SAMBASHARE]”

Loaded services file OK.

Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters

[global]

netbios name = CENTOS

server string = Samba Server %v

map to guest = Bad User

security = USER

dns proxy = No

idmap config * : backend = tdb

[SAMBASHARE]

path = /samba

guest ok = Yes

read only = No

[root@server samba]#

Enable and Start the Samba service

Start samba services, and enable them to start automatically on every reboot.

[root@server ~]# systemctl start smb
[root@server ~]# systemctl enable smb

Create a directory and change the permision

[root@server ~]# mkdir -p /samba/

[root@server ~]# chmod -R 0755 /samba/

[root@server ~]# chown -R nobody:nobody /samba/

Further we need to allow the selinux for the samba configuration as follows:

[root@server ~]# chcon -t samba_share_t /samba/

Now you can access the Centos 7.0 sharing in windows as follows, go to the Run prompt and type \192.168.1.10

image2

samba_share

Now samba user can browse & create new text documents:

samba_share_file

Check the file

check_file

Advertisements