1、配置
systemctl stop iptables.service ###关闭火墙yum install samba-client.x86_64 samba-common.x86_64 samba.x86_64 -y
systemctl start smb
ss -anutple |grep smb ###查看端口
2、smbclient -L //172.25.254.200 ###本机登陆查看 不用输入密码
3、smbpasswd -a student ###创建本地用户
smbclient -L //172.25.254.200 -U student ###查看本地用户
smbclient //172.25.254.108/student -U student ####登陆本地用户
pdbedit -L ####查看smb 用户
4、匿名用户查看
客户端
systemctl stop firewalldsmbclient -L //172.25.254.200 匿名用户登陆查看
mount -o username=student,password=321 //172.25.254.200/student /mnt ###将student 用户挂载在mnt下
touch /mnt/file ### 在smb中建立文件
smbclient //172.25.254.108/student -U student ####登陆本地用户
5、新建一个共享目录
vim /etc/samba/smb.conf
comment=my share ###解释
path=/share ####路径
systemctl restart smb
mkdir /share
restorecon -RvvF /share
touch /share/smbfile{1..3}
6、访问cifs 共享
smbclient //172.25.254.200/share -U student
vim /etc/fstab ###永久挂载
//172.25.254.200/share /mnt cifs defaults,username=student,password=123 0 0
mount -a 生效
8、匿名用户可以登陆
vim /etc/samba/smb.conf
map to guest= bad user
321 [wy]
322 comment=man wy
323 path=/wy
324 guest ok =yes
mount //172.25.254.200/share /mnt/ -o username=guest
9、用户及其用户组可写
共享文件一般是不可写的,在挂载在/mnt 下的共享目录里建立文件被拒绝
我们可以修改配置文件使用户对其可写入
vim /etc/samba/smb.conf
326 guest ok =yes327 writable = yes
setfacl -m u:student:rwx /share
测试:
用户组可写
vim /etc/samba/smb.conf
322 comment=my share
323 path=/share
324 guest ok =yes
325 writable = yes
326 write list= @student
327 valid users =student ####只有student可以登陆
328 valid users =+student ####只有student组可以登陆
setfacl -m g:student:rwx /share
usermod -G student tom
客户端:
mount //172.25.254.200/share /mnt/ -o username=tom,password=123
touch /mnt/file
10、建立超级用户
注:在服务器上对文件的管理是root 不是smb的超级用户
vim /etc/samba/smb.conf324 guest ok =yes
325 writable = yes
326 #write list= @student
327 admin users =admin
systemctl restart smb
客户
mount //172.25.254.200/wy /mnt/ -o username=student,password=123
11、共享目录隐藏
browseable = no ####目录对用户不可见
修改后,原先共享的share被隐藏
12、smb 多用户登陆
在客户端
yum install cifs-utils -ymount -o credentials=/root/smbfile,multiuser,sec=ntlmssp //172.25.254.200/share /mnt
vim /root/smbfile
username=student
password=321
su - student
ls ###没权限