一、samba中的多用户挂载
当使用普通挂载方式时
mount //192.168.0.111/wangdir -o username=wang,password=wang /mnt
切换到普通用户时,即使普通用户没有经过用户认证也可以访问挂载在/mnt中的远程服务端的内容,这样会带来安全隐患
使用文件认证的方式进行挂载
首先编辑指定的认证文件/root/smbpass,写入服务端中存在的samba用户以及密码
username=dan
password=dan
在客户端下载cifs文件系统工具
dnf search cifs
dnf install cifs-utils.x86_64 -y
使用特定参数进行挂载
credentials | 指定认证文件 |
---|---|
sec | 指定认证类型 |
multiuser | 支持多用户访问 |
mount -o credentials=/root/smbpass,sec=ntlmssp,multiuser //192.168.0.111/wangdir /mnt
由于在客户端用户wang中使用samba服务端中的用户dan进行登录,所以在上图中新建的文件file3的拥有者及拥有组应该为dan
二、autofs+samba
autofs:在客户端中安装的软件,实现自动挂载以及自动卸载
配置文件在etc/auto.master
在客户端中安装下载autofs
dnf search autofs
dnf install autofs.x86_64 -y
更改配置文件
vim /etc/auto.master
编辑自动挂载策略文件
vim /etc/auto.samba
更改挂载和卸载相互转换时的时长
vim /etc/autofs.conf
在客户端进行测试
三、nfs
3.1 nfs的基本信息及启用
安装包:nfs-utils.x86_64
服务脚本:nfs-server
共享配置文件:/etc/exports
安装
dnf search nfs
dnf install nfs-utils.x86_64 -y
启用
systemctl enable --now nfs-server.service
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --reload
测试:
编辑配置文件
vim /etc/exports
在客户端进行测试
编辑配置文件
在11主机中测试
在10主机中测试
编辑配置文件
测试
在服务端查看新建文件的属性
编辑配置文件
测试
四、nfs+autofs
类似于samba+autofs的使用方式
编辑客户端配置文件
vim /etc/auto.master
编辑自动挂载策略文件
测试