#1.samba服务的安装及访问调试
yum install samba-common.x86_64 samba-client samba.x86_64
systemctl stop firewalld
setsebool -P samba_enable_home_dirs on
smbpasswd -a student ##student必须是本机用户
pdbedit -L ##查看
pdbedit -x student ##删除
#测试
smbclient -L //172.25.254.238 -U student
smbclient //172.25.254.238/student -U student
#2.samba 共享目录
vim /etc/samba/smb.conf
[HAHA] ##共享名称
comment = /westos ##共享说明
path = /westos ##共享目录路径
:wq
systemctl restart smb
#共享目录建立是需要修改selinux属性。
semanage fcontext -a -t samba_share_t ‘/westos(/.*)?’
restorecon -FvvR /westos
#共享系统建立目录需要修改selinux属性,此方法修改针对所有目录,一旦开放,selinux不保护目录访问
setsebool samba_export_all_ro on ##只读
setsebool samba_export_all_rw on ##可以读写
#测试
vim /etc/samba/smb.conf
[NIUBI]
comment = /mnt
path =/mnt
:wq
smbclient //172.25.254.238/NIUBI -U studen
#3.samba的黑白名单
[HAHA]
comment = /westos
path = /westos
hosts allow = 172.25.254. ##允许此网段的用户挂载
hosts deny =172.25.254.138 ##禁止138用户挂载
#测试
238主机:
mount //172.25.254.238/HAHA /mnt/ -o username=student,password=westos
138主机:
mount //172.25.254.238/HAHA /mnt/ -o username=student,password=westos
#4.匿名用户访问
vim /etc/samba/smb.conf
5 map to guest = bad user
42 [NIUBI]
43 comment = /mnt
44 path = /mnt
45 guest ok = yes
#测试
mount //172.25.254.238/NIUBI /mnt/ -o username=guest
smbclient //172.25.254.238/NIUBI
此时匿名即可访问,也可挂载
#5.samba共享目录的管理参数
vim /etc/samba/smb.conf
[HAHA]
comment = /westos
path = /westos
guest = yes ##匿名用户登陆
writable = yes ##对在所有用户可写
write list = @student ##对student组用户可写
write list = student ##对student用户可写
valid users = student ##对student用户可登陆
valid users = +student ##对student组用户可登陆
browseable = no ##设定该目录允许被浏览,不隐藏
admin users = student ##指定管理用户
#6.smb多用户挂载
在客户端主机:
yum install cifs-utils
vim /root/smbpass
username=student
password=westos
:wq
mount -o credentials=/root/smbpass,multiuser,sec=ntlmssp //172.25.254.238/HAHA /mnt
#测试
su test
cifscreds add -u student 172.25.254.238
ls /mnt ##查看成功