- 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
[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
[root@desktop0 ~]# vim /etc/fstab
.. ..
[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
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 5月 2 12:52 1.txt
-rw-r--r--. 1 harry harry 0 5月 2 14:07 2.txt