Tuesday, December 25, 2012

Enable Samba server in CentOS 6.3

  1. Install Samba
    yum install samba samba-common 
  2. Edit Samba config file
    vi /etc/samba/smb.conf
    1. In the [global] section
              security = user
              passdb backend = tdbsam
              # Set to follow symbolic links
              follow symlinks = yes
              wide links = yes
              unix extensions = no
    2. In the [homes] section
              comment = Home Directories
              browseable = no
              writable = yes
              valid users = %S
              create mask = 0664
              directory mask = 0775
  3. Enable Samba in run levels 2, 3, 4, 5
    chkconfig --levels 2345 smb on
  4. Start the just installed Samba
    /etc/init.d/smb start
  5. Add users with default password as user name
    for i in user1 user2 user3 user4 user5
    do
            echo -e $i\\n$i | smbpasswd -a -s $i
    done
  6. Add these lines to /etc/sysconfig/iptables
    -A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
    -A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
  7. Restart iptables
    service iptables restart
  8. Let SELinux enable Samba home dirs
    setsebool -P samba_enable_home_dirs on
For more details, see http://wiki.centos.org/HowTos/SetUpSamba

No comments: