- SAMBA
- 创建samba共享,本地目录为/data/share1,要求:
- 共享名为share1。
- 仅允许zsuser用户能上传文件。
- 创建samba共享,本地目录为/data/public,要求:
- 共享名为public。
- 允许匿名访问。
- 所有用户都能上传文件。
一、安装samba服务以及客户端
[root@storagesrv /]# yum install samba samba-client -y
二、创建共享目录并设置权限
[root@storagesrv /]# mkdir -p /data/share1
[root@storagesrv /]# mkdir -p /data/public
[root@storagesrv /]# chmod -R 777 /data/
三、添加samba用户及权限
[root@storagesrv /]# useradd zsuser
[root@storagesrv /]# smbpasswd -a zsuser
New SMB password:
Retype new SMB password:
Added user zsuser.
四、配置主文件
[root@storagesrv /]# vim /etc/samba/smb.conf
[share1]
path = /data/share1 #路径
write list = zsuser #允许上传的用户
[public]
path = /data/public
guest ok = yes #开启匿名登录
writeable = yes #开启读写
[root@storagesrv /]# systemctl restart smb.service
五、测试服务
[root@storagesrv /]# smbclient //localhost/share1 -U zsuser
Enter SAMBA\zsuser's password:
Try "help" to get a list of possible commands.
smb: \> put /etc/1.txt
putting file / 1.txt (11.2 kb/s) (average 11.2 kb/s)
smb: \> quit
[root@storagesrv /]# smbclient //localhost/public
Enter SAMBA\root's password:
Anonymous login successful
Try "help" to get a list of possible commands.
smb: \> put /1.txt
putting file / as 1.txt (22.5 kb/s) (average 22.5 kb/s)
smb: \> quit
- SAMBA
- 安装与配置Samba共享服务;
- 创建目录为/share/public的共享目录
- 共享名为public;
- 仅支持匿名用户的只读访问(请在该目录内存放一个文件名为fletxt,文件内容为“Test File"以便于测试)创建目录为/share/files的共享目录;
- 共享名为files;
- 创建zhangsan,wangwu两个用户,密码均为Skills39,并目都能从cient客户端录访问到该共享目录并上传文件zhangsan用户可以查看和删除所有人的文件:
- wangwu用户只能查看和删除自己的文件,不能查看和删除别人的文件。
一、安装samba服务及其客户端
[root@storagesrv /]# yum install samba samba-client -y
二、创建samba文件目录
[root@storagesrv /]# mkdir /share/public -p
[root@storagesrv /]# mkdir /share/files -p
三、添加samba用户并配置权限
[root@storagesrv /]# useradd zhangsan
[root@storagesrv /]# useradd wangwu
[root@storagesrv /]# smbpasswd -a zhangsan
New SMB password:
Retype new SMB password:
Added user zhangsan.
[root@storagesrv /]# smbpasswd -a wangwu
New SMB password:
Retype new SMB password:
Added user wangwu.
[root@storagesrv /]# echo "Test File" > /share/public/file.txt
[root@storagesrv /]# chmod 777 -R /share/
[root@storagesrv /]# chmod o+t /share/files/
[root@storagesrv /]# chown zhangsan /share/files/
四、配置主配制文件
[root@storagesrv /]# nano /etc/samba/smb.conf
[public]
path = /share/public
read only = yes #只读
guest ok = yes #匿名登录
write list = zhangsan #允许上传的用户
[files]
path = /share/files
create mask = 0740 #创建文件等级
writeable = yes #开启读写
valid users = zhangsan,wangwu #允许用户
[root@storagesrv /]# systemctl restart smb
五、测试
[root@storagesrv /]# smbclient //localhost/public
Enter SAMBA\root's password:
Anonymous login successful
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Mon Aug 1 05:03:22 2022
.. D 0 Mon Aug 1 04:59:43 2022
file.txt N 10 Mon Aug 1 05:03:22 2022
17811456 blocks of size 1024. 16323756 blocks available
smb: \>
[root@StorageSrv ~]# smbclient //127.0.0.1/files -U Zhangsan
Enter SAMBA\Zhangsan's password:
Try "help" to get a list of possible commands.
smb: \> mkdir test
smb: \> ls
. D 0 Mon Aug 1 05:08:16 2022
.. D 0 Mon Aug 1 04:59:43 2022
test D 0 Mon Aug 1 05:08:16 2022
17811456 blocks of size 1024. 16323760 blocks available
smb: \> q
[root@storagesrv /]# smbclient //localhost/files -U wangwu
Enter SAMBA\wangwu's password:
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Mon Aug 1 05:08:16 2022
.. D 0 Mon Aug 1 04:59:43 2022
test D 0 Mon Aug 1 05:08:16 2022
17811456 blocks of size 1024. 16323760 blocks available
smb: \> rmdir test\
NT_STATUS_ACCESS_DENIED removing remote directory file \test\
smb: \>