This how-to presents the minimal configuration of the samba server with sample share without any access restrictions. More information on these can be found in html manual or man smb.conf.
INSTALLATION
[root@server ~]# yum install samba
Helpful docs:
[root@server ~]# firefox /usr/share/doc/samba-3.0.33/htmldocs/index.html
Mark to run on boot:
[root@server ~]# chkconfig smb on
IPTABLES
Grep /etc/services for netbios and microsoft-ds to determine the ports that need to be opened:
[root@server ~]# grep -i microsoft-ds /etc/services
microsoft-ds 445/tcp
microsoft-ds 445/udp
[root@server ~]# grep -i netbios /etc/services
netbios-ns 137/tcp # NETBIOS Name Service
netbios-ns 137/udp
netbios-dgm 138/tcp # NETBIOS Datagram Service
netbios-dgm 138/udp
netbios-ssn 139/tcp # NETBIOS session service
netbios-ssn 139/udp
Add the iptables rules:
[root@server ~]# iptables -I MYCHAIN -s 192.168.1.0/24 -p tcp --dport 137:139 -j ACCEPT
[root@server ~]# iptables -I MYCHAIN -s 192.168.1.0/24 -p udp --dport 137:139 -j ACCEPT
[root@server ~]# iptables -I MYCHAIN -s 192.168.1.0/24 -p tcp --dport 445 -j ACCEPT
[root@server ~]# iptables -I MYCHAIN -s 192.168.1.0/24 -p udp --dport 445 -j ACCEPT
[root@server ~]# service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
[root@server ~]#
MINIMAL CONFIGURATION
In /etc/samba/smb.conf add the following lines
[sambashare]
comment = My Samba Share
path = /samba
Create the samba share directory and set right SELINUX context:
[root@server ~]# mkdir /samba
[root@server ~]# touch /samba/file
[root@server ~]# semanage fcontext -a -t samba_share_t "/samba(/.*)?"
[root@server ~]# restorecon -Rv /samba/
restorecon reset /samba context user_u:object_r:default_t:s0->system_u:object_r:samba_share_t:s0
[root@server ~]# ls -Z /samba/
[root@server ~]# ls -Z / |grep samba
drwxr-xr-x root root system_u:object_r:samba_share_t samba
Add your user to the samba users:
[root@server ~]# smbpasswd -a piotr
New SMB password:
Retype new SMB password:
Added user piotr.
VERIFICATION
Verbose option provides some more information that might be helpful in debugging. My common mistake is, that I mimic the mount.nfs syntax and after server.example.com/ I put the path to my share. Here we use the name of the samba share which is string embraced between [] in smb.conf. On the client host:
[root@piotr ~]# mount -t cifs //server.example.com/sambashare /mnt/sambashare/ --verbose -o user=piotr
Password:
mount.cifs kernel mount options: ip=192.168.1.1,unc=\\server.example.com\sambashare,,ver=1,user=piotr,pass=********
[root@piotr ~]# cd /mnt/sambashare/
[root@piotr sambashare]# ll
total 4
-rw-r--r-- 1 root root 0 Oct 26 00:36 file