一、samba服务器
1、安装samba包
# yum -y install samba
2、创建用户组
# groupadd -r admins
# useradd -s /sbin/nologin -G admins smb1
# useradd -s /sbin/nologin -G admins smb2
# id smb1 && id smb2
uid=1005(smb1) gid=1005(smb1) groups=1005(smb1),994(admins)
uid=1003(smb2) gid=1003(smb2) groups=1003(smb2),994(admins)
3、创建samba用户
# smbpasswd -a smb1
New SMB password: #123456
Retype new SMB password:
Added user smb1.
# smbpasswd -a smb2
New SMB password: #654321
Retype new SMB password:
Added user smb2.
# pdbedit -L # 查看用户列表
smb1:1005:
smb2:1003:
4、创建samba共享目录
# mkdir /www
# chgrp admins /www
# chmod 2775 /www
5、添加配置文件
# vi /etc/samba/smb.conf
#在最下面添加即可
[share]
path = /www
write list = @admins
6、启动samba服务
# systemctl enable --now smb nmb
二、客户端
1、安装客户端连接工具
# yum -y install cifs-utils
2、客户端挂载CIFS文件系统
# mkdir /mnt/smb{1,2} -pv
mkdir: created directory '/mnt/smb1'
mkdir: created directory '/mnt/smb2'
# mount -o username=smb1 //10.0.0.7/share /mnt/smb1
Password for smb1@//10.0.0.7/share: ******
# mount -o username=smb2 //10.0.0.7/share /mnt/smb2
Password for smb2@//10.0.0.7/share: ******
# df -h
tmpfs 376M 0 376M 0% /run/user/0
//10.0.0.7/share 50G 1.7G 49G 4% /mnt/smb1
//10.0.0.7/share 50G 1.7G 49G 4% /mnt/smb2
三、测试
#可写测试
# touch /mnt/smb1/smb1file.txt
# touch /mnt/smb2/smb2file.txt
# echo "hello smb1" > /mnt/smb1/smb1file.txt
# echo "hello smb2" > /mnt/smb2/smb2file.txt
# 可读测试
# cat /mnt/smb1/smb1file.txt
hello smb1
# cat /mnt/smb2/smb2file.txt
hello smb2