Create a SMB share on CentOS

December 8, 2016 | Views: 3393

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

Disable SELinux
For the sake of simplicity and saving time, we will be disabling SELinux, which isn’t recommended. We urge you to learn how SELinux works and to set it up accordingly after getting samba working successfully.

This will disable SELinux from being enabled on boot:
vi /etc/selinux/config
Change “SELINUX=enforcing” to “SELINUX=disabled”

Run this to immediately disable SELinux without rebooting:
setenforce 0

Allows Samba Ports in Iptables
Change 10.0.0.0/24 to the subnet you wish to allow access to your samba server
Iptables -A INPUT -s 10.0.0.0/24 -p udp –dport 137 -j ACCEPT
Iptables -A INPUT -s 10.0.0.0/24 -p udp –dport 137 -j ACCEPT
Iptables -A INPUT -s 10.0.0.0/24 -p udp –dport 137 -j ACCEPT
Iptables -A INPUT -s 10.0.0.0/24 -p udp –dport 137 -j ACCEPT
Service iptables save

Install Samba
yum install samba samba-client samba-common

Set Samba to start on boot
chkconfig smb on
chkconfig nmb on

Create a samba user
useradd samba
groupadd sambagroup
usermod -a -G sambagroup samba

Create the share directory
mkdir /home/samba/private

Give the share directory the correct permissions
chown -R samba:sambagroup /home/samba/private
chmod -R 0770 /home/samba/private

Backup the default smb config
mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

Edit the smb config
vi /etc/samba/smb.conf

Add the following and adjust how you see fit:
[global] workgroup = WORKGROUP
security = share
map to guest = bad user

[Secure] path = /home/samba/private
valid users = @sambagroup
guest ok = no
writable = yes
browsable = yes

Start Samba
service smb start
service nmb start

Share with Friends
FacebookTwitterLinkedInEmail
Use Cybytes and
Tip the Author!
Join
Share with Friends
FacebookTwitterLinkedInEmail
Ready to share your knowledge and expertise?
1 Comment
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Cybrary On The Go

Get the Cybrary app for Android for online and offline viewing of our lessons.

Get it on Google Play
 

Support Cybrary

Donate Here to Get This Month's Donor Badge

 
Skip to toolbar

We recommend always using caution when following any link

Are you sure you want to continue?

Continue
Cancel