配置samba共享 一个用户有权限 多个用户可以借此用户访问

  • Samba :
    - 用途:为客户机提供共享使用的文件夹
    - 协议: SMB(TCP 139) , CIFS( TCP 445)

服务端:

防火墙设置为trusted
 [root@server0 ~]#  firewall-cmd --set-default-zone=trusted
创建samba用户:
[root@server0 ~]# useradd harry
[root@server0 ~]# pdbedit -a harry
new password:
retype new password:
服务器要装samba 起服务
[root@server0 ~]# yum -y install samba
[root@server0 ~]# systemctl restart smb
[root@server0 ~]# systemctl enable smb
创建共享目录
[root@server0 ~]#  mkdir /common
[root@server0 ~]# touch 1234 > /common/1.txt
修改配置文件
[root@server0 ~]# vim /etc/samba/smb.conf
.. .. 
[common]                    //共享目录
path = /common              //实际路径
write list = harry     
.. ..


[root@server0 ~]#systemctl restart smb
[root@server0 ~]#systemctl enable smb
开启SELinux 读写权限
[root@server0 ~]# getsebool -a | grep samba       //查找关于samba的权限
[root@server0 ~]# setsebool -P samba_export_all_rw on    //开启永久读写权限
单独为用户设置ACL权限
[root@server0 ~]#setfacl -m u:harry:rwx /common

客户端:

防火墙设置为trusted
 [root@server0 ~]#  firewall-cmd --set-default-zone=trusted
安装客户端:
[root@desktop0 ~]# yum -y install samba-client 
[root@desktop0 ~]# yum -y install cifs-utils
创建目录:
[root@desktop0 ~]# mkdir /mnt/nsd11
查看共享 修改配置文件
[root@desktop0 ~]#  smbclient -L 172.25.0.11       //查看共享名
[root@desktop0 ~]#  smbclient -U harry //172.25.0.11/common      //查看共享内容


[root@desktop0 ~]# vim /etc/fstab
.. ..
//172.25.0.11/common /mnt/nsd11 cifs username=harry,password=123456,multiuser,sec=ntlmssp,_netdev 0 0


[root@desktop0 ~]# mount -a
[root@desktop0 ~]# df -h

在客户端任何用户 都可借助harry 对/mnt/nsd11 读取写入

[root@desktop0 ~]# su - student      //任何用户都可以
[student@desktop0 ~]$ cifscreds -u harry add 172.25.0.11    //借harry 之名 读取写入信息
Password: 
[student@desktop0 ~]$ ls  /mnt/nsd11
1.txt  
[student@desktop0 ~]$ touch /mnt/nsd11/2.txt
[student@desktop0 ~]$ls
1.txt 2.txt
服务端:

[root@server0 ~]# ll /common
总用量 2
-rw-r--r--. 1 root root 5 52 12:52 1.txt
-rw-r--r--. 1 harry harry 0 52 14:07 2.txt   //属主属组 都是harry
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值