Friday, March 25, 2011

Configuring SAMBA on CentOS/RHEL

Configuring Samba on CentOS/RHEL to share data with Windows

suppose we want to share one directory with multiple users e.g. shah and king.

# groupadd share

# useradd -G share shah
# useradd -G share king

# mkdir /data

# chgrp share /data

# chmod g+rwx,o-rwx /data

Now if you are looking to enable group in-inheritance on directory:

# chmod g+s /data

If you want to enable sticky bit to keep data secure from other member of group or you do not want other members to delete sub-content of directory:

# chmod o+s /data

Now, install following rpms using Yum:

# yum install samba samba-client samba-common -y



Edit samba config file:


# vim /etc/samba/smb.conf


Put following content:


[share]
comment = Share Group's Stuff
path = /data
valid user= shah , king
public = yes
writable = yes
printable = no
write list = +staff

Details of Config:

[share] - #share name to be visible on windows
comment - #User prompt message for windows
valid user - #User name which you want to use for access
path - #Path of dir which you are looking to share
public - #share should be visible to other users
writable - #User should allowed to write from windows or smb shell
printable - #It is a share not printer
write list - #list of users or group who is allowed to write on share


Search for "hosts allow" in smb.conf to define hosts access :

hosts allow = 127. 192.168.12. 192.168.13. 192.168.1.20

Save and close the file. And define samba user's passwords:

# smbpasswd -a shah

# smbpasswd -a king


Start samba service:

# service smb start

Enable samba service at boot-up:

# chkconfig smb on

To verify shared dir or config:

# testparm

Now access share on windows:

Windows--> run --> \\smb-server_or_ip.ad.dr.ess


It will prompt for the user/password. Enter ;) and have fun.

No comments: