1.安装服务
[root@client ~]# yum install samba samba-common samba-client.x86_64 -y
[root@client ~]# systemctl start smb nmb
[root@client ~]# systemctl enable smb nmb
2.添加用户
[root@client ~]# smbpasswd -a student ##添加student用户
New SMB password: ##输入smb当前用户密码
Retype new SMB password: ##确认密码
Added user student.
[root@client ~]# pdbedit -L ##列出所有用户名
student:1000:User student[root@client ~]# pdbedit -x student ##删除用户名
[root@client ~]# setsebool samba_enable_home_dirs=1 ##在selinux上设置布尔值使smb用户可以访问自己的家目录
3.共享目录设定
[root@localhost ~]# vim /etc/samba/smb.conf
[haha] ##共享名称
comment = local directory ##对共享目录的描述
path = /smbshare ##共享目录的绝对路径
valid users = ##当前共享的有效用户
valid users = westos ##当前共享的有效用户
westos valid users = @westos ##当前共享的有效用户为westos组
valid users = +westos ##当前共享的有效用户为westos组
测试
mount -o username=student,password=redhat //172.25.254.119/haha /mnt touch在client上
vim /root/haha ##用户文件 username=student password=redhat chmod 600 /root/haha yum install cifs-utils -y mount -o credentials=/root/haha,multiuser,sec=ntlmssp //172.25.254.119/haha /mnt ##credentoals=/root/haha 指定挂载时所用到的用户文件 ##multiuser 支持多用户认证 ##sec=ntlmssp 认证方式为标准smb认证方式 12345678910 12345678910
测试
su - kiosk ls /mnt ls: cannot access /mnt: Permission denied ##因为没有做smb的认证 所以无法访问smb共享 cifscreds add -u westos 172.25.254.119 ##添加用户认证 Password: ##smb用户认证的密码 ls /mnt