1、在服务端上配置SMB服务,要求:
共享/common目录,共享名必须为 common,可以在common目录里面创建文件。
服务端安装(172.24.8.128):
[root@server-1 ~]# yum install samba -y
客户端安装(172.24.8.131):
[root@client_1 ~]# yum install samba-client -y
服务端配置文件(172.24.8.128):/etc/samba/smb.conf
[common]
comment = gonggong de
path = /commom
browseable = yes
writeable = yes
write list = xiaosan
添加一个用户xiaosn,并给其设置smb密码,创建共享目录/common,并给目录增加o+w的权限,重启服务
[root@server-1 ~]# useradd xiaosan
[root@server-1 ~]# smbpasswd -a xiaosan
New SMB password:
Retype new SMB password:
Added user xiaosan.
[root@server-1 ~]# mkdir /common
[root@server-1 /]# chmod o+w /common/
[root@server-1 ~]# cd /common/
[root@server-1 common]# echo "123" >file
[root@server-1 common]# cat file
123
[root@server-1 common]# systemctl restart smb nmb
客户端挂载目录到本地(172.24.8.131):
[root@client_1 ~]# mkdir /common #客户端挂载目录
[root@client_1 ~]# smbclient -L //172.24.8.128/common -U xiaosan
Enter SAMBA\xiaosan's password:
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
public Disk gonggong de
common Disk gonggong de
IPC$ IPC IPC Service (Samba 4.14.5)
xiaosan Disk Home Directories
挂载,并创建文件,删除文件来验证权限
[root@client_1 ~]# mount //172.24.8.128/common /common -o username=xiaosan,password=123
[root@client_1 ~]# cd /common/
[root@client_1 common]# touch file1 #创建文件
[root@client_1 common]# ll
total 4
-rwxr-xr-x. 1 root root 4 Dec 24 17:08 file
-rwxr-xr-x. 1 root root 0 Dec 24 17:27 file1
[root@client_1 common]# rm -f file1 #删除文件
[root@client_1 common]# ll
total 4
-rwxr-xr-x. 1 root root 4 Dec 24 17:08 file