關(guān)閉SELinux
# 臨時關(guān)閉
setenforce 0
# 修改配置文件
vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
安裝samba
yum install samba samba-client samba-swat
安裝成功之后查看服務(wù)狀態(tài)
service smb status
# 以下是狀態(tài) 未啟動 證明安裝成功
smb.service - Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
Active: inactive (dead)
添加開機(jī)啟動
chkconfig --level 35 smb on
取消開機(jī)啟動
chkconfig --level 35 smb off
配置
添加 share 并指定目錄 /home/share
vim /etc/samba/smb.conf
# 修改為如下內(nèi)容
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.
[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
# map to guest = Bad Password
#guest account = guest
[share]
comment = share folder
path = /home/share
create mask = 0664
directory mask = 0775
browseable = yes
writable = yes
public = yes
運(yùn)行 testparm 檢查配置是否正確
testparm
添加用戶
運(yùn)行下面命令 添加root用戶并設(shè)置密碼
smbpasswd -a root
啟動并查看狀態(tài)
service smb start
service smb status
客戶端安裝并映射
1. 安裝映射工具
yum install cifs-utils
2. mount映射
mount -t cifs //serviceip//share /home/share -o username=root,password=123123
3. 取消映射
umount /home/share
4. 添加開機(jī)自動映射
vim /etc/fstab
#追加
//serviceip/share /home/share cifs defaults,auto,username=root,password=123123 0 0