Samba-Server

Samba server installation on CentOS 6.5
=======================================


Basic-samba Server
==================


Install the samba package

# yum install samba samba-client samba-common

Check the version of installed samba

# smbd --version


Configure the samba service to start automatically at boot time:

# chkconfig smb on
# chkconfig nmb on



Add these Iptables rules/Disable IPTables

# iptables -I INPUT 4 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
# iptables -I INPUT 5 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
# iptables -I INPUT 6 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
# service iptables save


Backup the smb.conf file and create the new one:

# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
# >/etc/samba/smb.conf
# vi /etc/samba/smb.conf


#====== Global Settings =====
[global]
workgroup = WORKGROUP
security = share
map to guest = bad user
#==== Share Definitions =====
[Samba-Share]
path = /SMB/Data
browsable =yes
writable = yes
guest ok = yes
read only = no


#

Save the smb.conf file and restart the service:

# service smb restart
# service nmb restart


Change permission for samba share:

# chmod -R 0777 /SMB/Data



Secured - Samba
===============

Add a group in your CentOS server:

# useradd test
# groupadd smbgrp
# usermod -a -G smbgrp test
# smbpasswd -a test


Create a new share, set the permission on the share:

# mkdir /SMB/Data-Sec
# chown test:smbgrp /SMB/Data-Sec
# chmod 0770 /SMB/Data-Sec


Edit the smb.conf file:

# vi /etc/samba/smb.conf


#====== Global Settings =====
[global]
workgroup = SambA
security = user
#==== Share Definitions =====
[Secure]
path = /SMB/Data-Sec
valid users = @smbgrp
guest ok = no
writable = yes
browsable = yes
create mask = 0644
directory mask = 0755


#


Restart the samba service:

# service smb restart
# service nmb restart



Check the syntax error with testparm:

# testparm


For Printer-Sharing
=====================


# vi /etc/samba/smb.conf
[global]
    workgroup = SambA
    log file = /var/log/samba/log.%m
    max log size = 50
    security = user
    passdb backend = tdbsam
    load printers = yes
    printing = cups
    printcap name = cups
[printers]
    comment = All Printers
    path = /var/spool/samba
    browseable = yes
    guest ok = yes
    printable = yes
        read only = yes 
        create mask = 0700
[print$]
    comment = Printer Drivers
    path = /var/lib/samba/printers
    browseable = yes
    read only = yes
    guest ok = yes

#


===================================

"Soft" and "ISO" Shares as ReadOnly and "Data" share as Writable


# egrep -v "^#|^$" /etc/samba/smb.conf
[global]
    workgroup = SambA
    log file = /var/log/samba/log.%m
    max log size = 50
    security = user
    passdb backend = tdbsam
    load printers = yes
    printing = cups
    printcap name = cups
[printers]
    comment = All Printers
    path = /var/spool/samba
    browseable = yes
    guest ok = yes
    printable = yes
    read only = yes 
    create mask = 0700
[print$]
    comment = Printer Drivers
    path = /var/lib/samba/printers
    browseable = yes
    read only = yes
    guest ok = yes
[Softs]
    comment = 4-Clone
    path = /Clone/Samba/Softs
    public = yes
    writable = no
    printable = no
    valid users = test
    create mask = 0644
    directory mask = 0755

[ISO]
    comment = 4-Clone
    path = /Clone/Samba/ISO
    public = yes
    writable = yes
    printable = no
    valid users = centos, test
    create mask = 0644
    directory mask = 0755
[Data]
    comment = 4-Clone
    path = /Clone/Samba/Public
    public = yes
    writable = yes
    printable = no
    guest ok = yes
    create mask = 0777
    directory mask = 0777

#

# ls -ld /Clone/Samba/ISO
drwxr-xr-x 9 centos centos 4096 Dec 15 15:16 /Clone/Samba/ISO
#

 Here user "centos" have the write permission on samba share "/Clone/Samba/ISO" while user test doesn't have even though defined in Samba conf.Because the system directory permission not allow the user to write.