![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to configure samba on centos
This article will guide to configure samba server in CentOS 6.x with anonymous & secured samba folders. Samba is an Open Source/Free Software suite that provides seamless access to the file services to SMB/CIFS clients. Unlike other tools samba SMB/CIFS implementations will allow to share folders between Linux servers and Windows clients.
Installation
Install the samba package using this command
# yum -y install samba # mkdir /samba
Give folder permission to the samba server
# chmod -R 0755 /samba/anonymous/
You need to modify the smb.conf file in /etc/samba/smb.conf
For security reasons, I am taking the backup of the original file in /etc/samba/smb.conf
# cp /etc/samba.smb.conf /etc/samba.smb.conf.old
For removing the confusion, will delete the configuration file and will create a file with the below commands.
# rm -rf /etc/samba.smb.conf # vi /etc/samba/smb.conf
Configuration File Settings
#======================= Global Settings ===================================== [global] workgroup = WORKGROUP security = share map to guest = bad user #============================ Share Definitions ============================== [MyShare] path = /samba/anonymous/ browsable =yes writable = yes guest ok = yes read only = yes
Start the Service Samba Server Services
# service smb restart
Accessing the Share from Windows
Now you can access the share from windows machine using \IP-ADDRES from Start -> Run. (Ex: \192.168.2.225)
Securing the Samba Share
As we share the files without any security there is a chance of loosing your valuable data to secure please do the settings.
# groupadd smbgrp # useradd user1 -G sambagrp # smbpasswd -a user1
Output: New SMB password:<--yoursambapassword Retype new SMB password:<--yoursambapassword
Now create the folder with the name secured in the /samba folder and give permissions like this −
# mkdir -p /samba/secure # cd /samba # chmod -R 0777 /samba/secure/
Again edit the configuration file −
# vi /etc/samba/smb.conf [...] [secured] path = /samba/secure valid users = @smbgrp guest ok = no writable = yes browsable = yes
# service smb restart
Further, check the settings as follows
# testparm Output: Load smb config files from /etc/samba/smb.conf rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) Processing section "[Anonymous]" Processing section "[secured]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions <--ENTER
Edit the Configuration files with both anonymous and secure to see the difference in shares.
# vi /etc/samba/smb.conf Configuration file settings:
#======================= Global Settings ===================================== [global] netbios name = CENTOS server string = Samba Server %v map to guest = Bad User dns proxy = No idmap config * : ackbend = tdb #============================ Share Definitions ============================== [Anonymous] path = /samba read only = No guest ok = Yes [secured] path = /samba/secure valid users = @smbgrp guest ok = no writable = yes browsable = yes
Now you can access the share from windows machine \IP-ADDRES from Start -> Run. (Ex: \192.168.2.225)
This will ask for the user-name and password provide the user-name and password (Ex: user1 and password for the user1) and now you can access the secured folder using credentials.
Conclusion − After the configuration and successful setup, now you are able to access the folder Windows share (or) NTFS share on a Linux server to provide or share the data in between Windows and Linux machines, with or without anonymous access and you are able to provide the individual access or groups access to the folders with permissions.