Вы находитесь на странице: 1из 23

SAMBA I
 29 and RHCE
Ebook: Introducing the RHCSA TecMint
Exam : 
Preparation Guide   
 BEGINNER'S GUIDE FOR LINUX 
How to Install Start learning Linux in minutes 

Samba4 on CentOS 7
for File Sharing on
Windows
by Aaron Kili | Published: July 1, 2017 | July 1,
2017

SPONSORED SEARCHES

Centos Samba Share

Linux Server
 Vi/Vim Editor BEGINNER'S GUIDE 
Learn vi/vim as a Full Text Editor 
 Download Your Free eBooks NOW - 10 Free
Linux eBooks for Administrators | 4 Free Shell
Scripting eBooks

In our last article, we SHARE


showed how to install
+
Samba4 on Ubuntu for basic
le sharing between Ubuntu 
systems and Windows
0
machines. Where we looked
at con guring anonymous 
(unsecure) as well as secure
0
le sharing.  Linux Foundation Certi cation 
 Exam Study Guide to LFCS and LFCE
Here, we will describe how
0
to install and con gure  
Samba4 on CentOS 7 (also

works on RHEL 7) for basic How to Add Linux Host to Nagios Monitoring
le sharing between other Server Using NRPE Plugin

Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide


Linux systems and Windows How to Install Nagios 4.3.4 on RHEL, CentOS and
Fedora
machines.
Install Cacti (Network Monitoring) on
Important: Starting from RHEL/CentOS 7.x/6.x/5.x and Fedora 24-12
version 4.0, Samba can run
as an Active Directory (AD) Google Chrome 70 Released – Install on
RHEL/CentOS and Fedora
domain controller (DC). We
suggest you read through
How to Install Ubuntu 16.10/16.04 Alongside With
our special series on setting Windows 10 or 8 in Dual-Boot
up Samba4 Active Directory
Domain Controller, which
includes critical topics for
Ubuntu, CentOS, and
Windows.

Install Samba4 in
CentOS 7
1. First install Samba4 and
required packages from the
default CentOS repositories
using the yum package
manager tool as shown.

# yum install samba sam

Linux System Administrator Bundle


with 7-Courses (96% off)

Install Samba4 on CentOS 7


Add to Cart - $69
 Ending In: 3 days

Computer Hacker Professional


Certi cation Course (96% Off)
Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide
2. After installing the samba Add to Cart - $59
packages, enable samba
 Ending In: 4 days
services to be allowed
through system rewall with
these commands. LINUX EBOOKS

Introducing Learn Linux In One Week and Go


# firewall-cmd --perman from Zero to Hero
# firewall-cmd --reload
RedHat RHCE/RHCSA Certi cation Preparation
Guide
Linux Foundations LFCS/LFCE Certi cation
Guide
Post x Mail Server Setup Guide for Linux
Open Samba on Firewalld
Ansible Setup Guide for Linux
Django Setup Guide for Linux
Check Windows Awk Getting Started Guide for Beginners
Machine Citrix XenServer Setup Guide for Linux

Workgroup
Settings     

3. Before you proceed to Never Miss Any Linux Tutorials,


con gure samba, make sure Guides, Tips and Free eBooks
the Windows machine is in Join Our Community Of 150,000+ Linux Lovers
the same workgroup to be and get a weekly newsletter in your inbox

con gured on the CentOS


YES! SIGN ME UP
server.

There are two possible ways


to view the Windows
machine workgroup
settings:

Right clicking on “This


PC” or “My Computer”
→ Properties →
Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide
Advanced system
settings → Computer
Name.

Check Windows WorkGroup

Alternatively, open the


cmd prompt and run the
following command,
then look for
“workstation domain” in
the output as shown
below.

>net config workstation

Verify Windows WorkGroup

Con guring
Samba4 on
CentOS 7
4. The main samba
con guration le is
Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide
/etc/samba/smb.conf, the
original le comes with pre-
con guration settings which
explain various con guration
directives to guide you.

But, before con guring


samba, I suggest you to take
a backup of the default le
like this.

# cp /etc/samba/smb.con

Then, proceed to con gure


samba for anonymous and
secure le sharing services
as explained below.

Samba4
Anonymous File
Sharing
5. First create the shared
directory where the les will
be stored on the server and
set the appropriate
permissions on the
directory.

# mkdir -p /srv/samba/a
# chmod -R 0775 /srv/sa
# chown -R nobody:nobod

Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide


Also, you need to change the
SELinux security context for
the samba shared directory
as follows.

# chcon -t samba_share_

Create Samba Shared Directory

6. Next, open the samba


con guration le for editing,
where you can modify/add
the sections below with the
corresponding directives.

# vi /etc/samba/smb.con

Samba Con guration Settings

[global]
workgroup = WOR
netbios name =
security = user
[Anonymous]
comment = Anony
path = /srv/sam
browsable =yes
writable = yes
guest ok = yes
read only = no
force user = no

7. Now verify current samba


settings by running the
Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide
command below.

# testparm

Verify Samba Current

Con guration Settings

Load smb config files f


rlimit_max: increasing
Processing section "[ho
Processing section "[pr
Processing section "[pr
Processing section "[An
Loaded services file OK
Server role: ROLE_STAND

Press enter to see a du

# Global parameters
[global]
netbios name =
printcap name =
security = USER
idmap config *
cups options =
[homes]
comment = Home
browseable = No
inherit acls =
read only = No
valid users = %
[printers]
comment = All P
path = /var/tmp
browseable = No
printable = Yes
create mask = 0
[print$]
comment = Print
path = /var/lib
create mask = 0
directory mask
write list = ro
[Anonymous]
comment = Anony
path = /srv/sam
force user = no
Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide
guest ok = Yes
read only = No

8. Finally, start and enable


samba services to start
automatically at next boot
and also apply the above
changes to take effect.

# systemctl enable smb.


# systemctl enable nmb.
# systemctl start smb.s
# systemctl start nmb.s

Testing Anonymous
Samba File Sharing
9. Now on the Windows
machine, open “Network”
from a Windows Explorer
window, then click on the
CentOS host, or else try to
access the server using its
IP address (use ifcon g
command to get IP
address).

e.g. \192.168.43.168.

Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide


Shared Network Hosts

10. Next, open the


Anonymous directory and
try to add les in there to
share with other users.

Samba Anonymous Share

Add Files to Samba Anonymous Share

Setup Samba4
Secure File
Sharing
11. First start by creating a
samba system group, then
add users to the group and
set a password for each
user like so. Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide
# groupadd smbgrp
# usermod tecmint -aG s
# smbpasswd -a tecmint

12. Then create a secure


directory where the shared
les will be kept and set the
appropriate permissions on
the directory with SELinux
security context for the
samba.

# mkdir -p /srv/samba/s
# chmod -R 0770 /srv/sa
# chown -R root:smbgrp
# chcon -t samba_share_

13. Next open the


con guration le for editing
and modify/add the section
below with the
corresponding directives.

# vi /etc/samba/smb.con

Samba Secure Con guration

Settings

[Secure]
comment = Secur
path = /srv/sa
valid users = @
guest ok = no
writable = yes
browsable = yes
Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide
14. Again, verify the samba
con guration settings by
running the following
command.

$ testparm

Verify Secure Con guration

Settings

Load smb config files f


rlimit_max: increasing
Processing section "[ho
Processing section "[pr
Processing section "[pr
Processing section "[An
Loaded services file OK
Server role: ROLE_STAND

Press enter to see a du

# Global parameters
[global]
netbios name =
printcap name =
security = USER
idmap config *
cups options =
[homes]
comment = Home
browseable = No
inherit acls =
read only = No
valid users = %
[printers]
comment = All P
path = /var/tmp
browseable = No
printable = Yes
create mask = 0
[print$]
comment = Print
path = /var/lib
create mask = 0
Ebook: Introducing
directory mask the RHCSA and RHCE Exam Preparation Guide
write list = ro
[Anonymous]
comment = Anony
path = /srv/sam
force user = no
guest ok = Yes
read only = No
[Secure]
comment = Secur
path = /srv/sam
read only = No
valid users = @

15. Restart Samba services


to apply the changes.

# systemctl restart smb


# systemctl restart nmb

Testing Secure
Samba File Sharing
16. Go to Windows machine,
open “Network” from a
Windows Explorer window,
then click on the CentOS
host, or else try to access
the server using its IP
address.

e.g. \192.168.43.168.

You’ll be asked to provide


your username and
password to login the
CentOS server. Once you
Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide
have entered the credentials,
click OK.

Samba Secure Login

17. Once you successfully


login, you will see all the
samba shared directories.
Now securely share some
les with other permitted
users on the network by
dropping them in Secure
directory.

Samba Secure Share Directory

You can also check out


these useful articles
concerning Samba le
sharing on a network.

How to
Mount/Unmount Local
and Network (Samba &
NFS) Filesystems in
Linux
Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide
Using ACLs (Access
Control Lists) and
Mounting Samba / NFS
Shares
How to Fix SambaCry
Vulnerability (CVE-
2017-7494) in Linux
Systems

In this guide, we showed you


how to setup Samba4 for
anonymous and secure le
sharing between CentOS
and other Linux systems as
well as Windows machines.
Share any thoughts with us
via the comment section
below.

If You Appreciate
What We Do Here On
TecMint, You Should
Consider:
1. Stay Connected to: Twitter |
Facebook | Google Plus

2. Subscribe to our email


updates: Sign Up Now

3. Get your own self-hosted


blog with a Free Domain at
Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide
($3.45/month).

4. Become a Supporter - Make


a contribution via PayPal

5. Support us by purchasing
our premium books in PDF
format.

6. Support us by taking our


online Linux courses

We are thankful for your never


ending support.

Tags: samba

Aaron Kili View all Posts


Aaron Kili is a

Linux and F.O.S.S enthusiast, an
upcoming Linux SysAdmin, web
developer, and currently a
content creator for TecMint
who loves working with
computers and strongly
believes in sharing knowledge.

Your name can also be


listed here. Got a tip?
Submit it here to
become an TecMint
author.

Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide


PREVIOUS NEXT STORY

STORY 13 Best VPN


Installation of Services with 
 Debian 9 Lifetime
(Stretch) Subscription
Minimal
Server

 YOU MAY ALSO LIKE...

0  16

Setup
Samba
How to
Server
Install
Using
Samba on
tdbsam
Ubuntu for
Backend on
File Sharing
RHEL/Cent
on
OS 6.3/5.8
Windows
and Fedora
22 JUN, 2017
17-12
21 AUG, 2012

Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide


8

How to Fix
SambaCry
Vulnerabilit
y (CVE-
2017-7494)
in Linux
Systems
29 MAY, 2017

Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide


29 RESPONSES

 Comments 7  Pingbacks 0

Paul  December 17, 2018 at 6:35 pm


Aaron, maybe this is a clue. I noticed the
testparm produces different text than
the smb.conf le.

Here it is:
smb.conf-
[Anonymous]
comment = Anonymous File Server Share
path = /srv/samba/anonymous
browsable = yes
writable = yes
guest ok = yes
read only = no
force user = nobody
account = nobody

testparm-
[Anonymous]
comment = Anonymous File Server Share
force user = nobody
guest ok = Yes
path = /srv/samba/anonymous
read only = No
Reply

Paul  December 14, 2018 at 8:46 pm


Thank you for the article. My problem is:
a dialog pops up “Windows Security”,
“Enter your password to connect to:
CENTOS” I have found the cryptic
network password under Control
Panel\Network and
Internet\HomeGroup\View and print
your home group password.
Reply

Man  December 12, 2018 at 6:57 pm


sorry admin
I still cannot gure out the sharing
Ebook: Introducing
without password the RHCSA
even I had follow your and RHCE Exam Preparation Guide
step. it still asking me username and
password.
Reply

Aaron Kili
 December 16, 2018 at 4:08 pm
@MN
Access without password is
only con gured for anonymous
access. Refer to the guide for
more information.
Reply

Paul
 December 17, 2018 at
4:58 pm
Yes. I am clear on the
limitation to the
anonymous folder. I
cannot see the
anonymous folder. The
password dialogue
appears and stops any
further progress.
Thanks for your help! I
appreciate your efforts.
Reply

Bob
 December 30,
2018 at 7:24 am
Same problem
here, the
solution is to
put:
map to guest =
Bad User
in the section
under
[Anonymous ]
Reply

Aaron
Kili

Ebook: Introducing theJanuary
RHCSA and RHCE Exam Preparation Guide
2, 2019
at 12:54
pm
@Bob

Many
thanks
for
sharing
this, we
truly
apprecia
your
contribu

« Older Comments

GOT SOMETHING TO SAY? JOIN THE


DISCUSSION.

Comment

Name * Email *

Website

Notify me of followup comments via e-


mail. You can also subscribe without
commenting.

Post Comment

This site uses Akismet to reduce spam. Learn


how your comment data is processed.
Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide
LINUX MONITORING TOOLS LINUX INTERVIEW QUESTIONS OPEN SOURCE TOOLS

GoAccess (A Real-Time 11 Advance MySQL 13 Best File Managers for


Apache and Nginx) Web Database “Interview Linux Systems
Server Log Analyzer Questions and Answers” for
Linux Users 6 Best PDF Page Cropping
Monitor Server Logs in Real- Tools For Linux
Time with “Log.io” Tool on 10 MySQL Database
RHEL/CentOS 7/6 Interview Questions for 6 Online Tools for
Beginners and Generating and Testing Cron
How to Use ‘fsck’ to Repair Intermediates Jobs for Linux
File System Errors in Linux
10 Advance VsFTP Interview 10 Best Markdown Editors
NetHogs – Monitor Per Questions and Answers – for Linux
Process Network Bandwidth Part II
Usage in Real Time 10 Top Open Source
Shilpa Nair Shares Her Arti cial Intelligence Tools
SARG – Squid Analysis Interview Experience on for Linux
Report Generator and RedHat Linux Package
Internet Bandwidth Management
Monitoring Tool
10 VsFTP (Very Secure File
Transfer Protocol) Interview
Questions and Answers

Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide



Tecmint: Linux Howtos, Tutorials & Guides © 2019.
All Rights Reserved.     
The material in this site cannot be republished
either online or o ine, without our permission.

Ebook: Introducing the RHCSA and RHCE Exam Preparation Guide

Вам также может понравиться