Install the Samba:
[root@frank ~]#yum -y install samba samba-client
Create a folder for samba share
[root@frank ~]#mkdir /home/share
Then give it the appropriate permission:
[root@frank ~]#chmod 777 /home/share
Configure the service
[root@frank ~]#vi /etc/samba/smb.conf
near line 66: add unix charset = UTF-8
line 90: change (Windows' default) workgroup = WORKGROUP line 98: uncomment max protocol = SMB2 line 96: uncomment and change to the IPs you permit to access hosts allow = 127. 10.0.0. line 126: add ( no auth ) security = user passdb backend = tdbsam map to guest = Bad User
add to the last line [Share] any name you like path = /home/share
writable = yes
guest ok = yes guest only = yes
create mode = 0777
directory mode = 0777
share modes = yes
start the smb service
[root@frank ~] systemctl start smb.service
[root@frank ~] systemctl start nmb.service
[root@frank ~] systemctl enable smb.service
[root@frank ~] systemctl enable nmb.service
Set firewall
Further CentOS 7.0 Firewall-cmd will block the samba access, to get rid of that we will run:
[root@server1 ~] firewall-cmd --permanent --zone=public --add-service=samba success [root@server1 ~] firewall-cmd --reload
Set Selinux
Turn the samba_domain_controller Boolean on to allow a Samba PDC to use the useradd
and groupadd
family of binaries. Run the following command as the root user to turn this Boolean on:
setsebool -P samba_domain_controller on
Turn the samba_enable_home_dirs Boolean on if you want to share home directories via Samba. Run the following command as the root user to turn this Boolean on:
setsebool -P samba_enable_home_dirs on
If you create a new directory, such as a new top-level directory, label it with samba_share_t so that SELinux allows Samba to read and write to it. Do not label system directories, such as /etc/ and /home/, with samba_share_t, as such directories should already have an SELinux label.
Run the “ls -ldZ /path/to/directory” command to view the current SELinux label for a given directory.
Set SELinux labels only on files and directories you have created. Use the
chcon command to temporarily change a label:
chcon -t samba_share_t /path/to/directory
To share such directories and allow read only permissions:
setsebool -P samba_export_all_ro on
To share such directories and allow read and write permissions:
setsebool -P samba_export_all_rw on