There is a new version of this tutorial available for CentOS 8.

Samba Server Configuration in CentOS 6.5

This tutorial exists for these OS versions

On this page

  1. 1 Preliminary Note
  2. 2 Anonymous samba sharing

This guide explains how to configure samba server in CentOS 6.5 with anonymous & secured samba servers. Samba is an Open Source/Free Software suite that provides seamless file and print services to SMB/CIFS clients. Samba is freely available, unlike other SMB/CIFS implementations, and allows for interoperability between Linux/Unix servers and Windows-based clients.

1 Preliminary Note

I have fresh installed centos 6.5 server, on which I am going to install the samba server. Off-course you need to have one windows machine to check the  samba server that must be reachable with the centos server. My centos server have hostname server1.example.com & IP as 192.168.0.100

You can have your centos server installed from the starting seven chapters of the tutorial.Just enable the epel repo & continue further.

Note:

  • There is no need to install the Developments-tools in chapter-7 of the tutorial.
  • The Windows machine must be on same workgroup. To check the value in windows machine run the command at cmd prompt
net config workstation

It will be like this



Your windows machine must be at same Workstation domain as in centos server, i.e. WORKGROUP in my case.

  • To make the windows machine reachable in windows proceed like this. In the run terminal & add  the entry of your server IP address
notepad C:\Windows\System32\drivers\etc\hosts

In my case it was like this, just save the values.

[...]
192.168.0.100 server1.example.com centos

2 Anonymous samba sharing

First I will explain the methodology to install the samba with the anonymous sharing. To install samba run,

yum install samba samba-client samba-common

It will install samba with Version 3.6.9-168.el6_5.

Now to configure samba edit the file /etc/samba/smb.cnf before making changes I will make the backup of original file as  /etc/samba/smb.cnf.bak

mv /etc/samba/smb.cnf /etc/samba/smb.cnf.bak

Further give the entries like this

vi /etc/samba/smb.cnf
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = centos
security = user
map to guest = bad user
dns proxy = no
#============================ Share Definitions ============================== 
[Anonymous]
path = /samba/anonymous
browsable =yes
writable = yes
guest ok = yes
read only = no
mkdir -p /samba/anonymous
chkconfig smb on
service smb restart
service nmb restart

Now you can access the centos sharing in windows as follows:

From windows machine just browse the folder& try to create a text file, but you will get an error of permission denied.



Check the permission for the shared folder.

[[email protected] samba]# ls -l
total 4
drwxr-xr-x 2 root root 4096 May 28 14:11 anonymous
[[email protected] samba]# 

To allow anonymous user give the permissions as follows:

[[email protected] ~]# cd /samba/
[[email protected] samba]# chmod -R 0777 anonymous/
[[email protected] samba]# ls -l
total 4
drwxrwxrwx 2 root root 4096 May 28 14:11 anonymous
[[email protected] samba]#

Now anonymous user can browse & create the folder contents.

You can cross check the content at server also.

[[email protected] samba]# ls -l anonymous/
total 0
-rwxr--r-- 1 nobody nobody 0 May 28 14:41 anonymous_test.txt
[[email protected] samba]#

Share this page:

Suggested articles

7 Comment(s)

Add comment

Comments

By: Anonymous

 If samba share is not allowed in selinux this wont work.. (default selinux is enforced)

 This step is missing in this guide.. 

chcon -R -t samba_share_t /samba/anonymous/

 

 Yet easy to understand excellent guide 

By: Anonymous

Thanks! Hours trying to figure out why mine is not working.

Just had to disable SELINUX.

By: Mark

 For CentOS 6.6 I was unable to get this to work. I've disabled SELinux and IPTables to reduce variables. Windows can't even see a file I put in the share.

By: Mark

My mistake was I created the directory to be shared at /etc/samba/anonymous and not /samba/anonymous 

By: James

For Step 2, to make a copy of the orginal config file shouldn't the command be cp /etc/samba/smb.cnf /etc/samba/smb.cnf.bak 

Using the mv command as stated will simpily just rename the file.

By: till

No, it should not be cp here. The reason to use mv is to get a backup plus remove the file as we want to start with an empty file.

 

So if you would use cp instead of MV then you would have to run one more command to get the desired result:

 

cp /etc/samba/smb.cnf /etc/samba/smb.cnf.bak

cat /dev/null > /etc/samba/smb.cnf

 

By: shetu

smb.cnf or smb.conf