server虚拟机
yum install samba samba-client.x86_64 samba-common -y
systemctl start smb
systemctl enable smb
systemctl stop firewalld
systemctl disable firewalld
useradd 123
useradd 124
smbpasswd -a 123
smbpasswd -a 124
pdbedit -L
pdbedit -x 124
pdbedit -L
getsebool -a | grep samba setsebool -P samba_enable_home_dirs on
desktop虚拟机
yum install samba-client.x86_64 -y
smbclient -L //172.25.15.11
smbclient //172.25.15.11/123 -U 123
server虚拟机
mkdir /samba
touch /samba/file{1..3}
vim /etc/samba/smb.conf
[WESTOS]
comment = /samba dir
path = /samba
[ETC]
comment = etc
path = /mnt
systemctl restart smb
semanage fcontext -a -t samba_share_t '/samba(/.*)?'
restorecon -FvvR /samba/
setsebool -P samba_export_all_ro on
desktop虚拟机
smbclient //172.25.15.11/WESTOS -U 123
smbclient //172.25.15.11/ETC -U 123
匿名
server虚拟机
vim /etc/samba/smb.conf
map to guest = bad user #125行
guest ok = yes #328行
systemctl restart smb
desktop虚拟机
smbclient //172.25.15.11/WESTOS
更改Domain
server虚拟机
vim /etc/samba/smb.conf
workgroup = XXX #89行
systemctl restart smb
desktop虚拟机
mount //172.25.15.11/WESTOS /mnt -o username=123,password=123
此时不能创建文件
server虚拟机
vim /etc/samba/smb.conf
writeable = yes #329行
systemctl restart smb
vim /etc/samba/smb.conf
删除上一步输入的329行
write list = +123 #是否可写 +或@表示组 #从329行开始
browseable = yes #是否可以通过smbclient -L //172.25.15.11列出
valid users = 123 #指定有效用户
admin users = 123 #提升用户权限,在共享文件夹权限为755时,使123用户可以进行操作
systemctl restart smb smaba
多用户挂载
预期目的
当在desktop端挂载了samba共享之后,可以通过/root/sambauserfile中的密码进行认证。但是只有在samba服务器中存在的用户才可以访问
server虚拟机
vim /etc/samba/smb.conf
[WESTOS]
comment = lalala
path = /smaba
browseable = yes
writeable = yes
systemctl restart smb #禁止匿名用户,取消提升用户权限以及有效用户的指定
desktop虚拟机
useradd 123 #建立和服务器端一样的用户
vim /root/sambauserfile
username=123
password=123 #为挂载提供一个用户,如果文件中用户在samba服务器中不存在,则无法挂载
yum install cifs-utils -y #认证所需软件
mount //172.25.15.11/WESTOS /mnt -o credentials=/root/sambauserfile,multiuser,sec=ntlmssp
su - XXX #切换不同用户进行实验
cifscreds add 172.25.15.11 #认证