AnolisOS8/CentOS8安装samba
[TOC]
安装samba服务
yum install samba -y
备份默认配置smb.conf
cd /etc/samba/
cp smb.conf smb.conf.bak #备份一下配置文件
无需认证匿名访问
vi smb.conf #修改配置文件
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.
[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
map to guest = Bad User
#?使用smb v1,根据需要选择,我的小米cam需要用v1才可以认上
client min protocol = NT1
server min protocol = NT1
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes
[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = @printadmin root
force group = @printadmin
create mask = 0664
directory mask = 0775
[smbshare]
#无需认证匿名访问配置
path=/data2/samba/mi_cam/ #共享路径
public=yes #公共
browseable=yes #读权限
writable=yes #写权限
create mask=0644 #设置权限
directory mask=0755
所设置的访问路径需要先创建并设置权限
mkdir -p /data2/samba/mi_cam/
chmod 777 /data2/samba/mi_cam/
启动服务
systemctl start smb.service
用户验证才可访问
创建samb用户和密码
useradd mi-cam #创建用户mi-cam
smbpasswd -a mi-cam #设置用户mi-cam的smb登录密码
vi smb.conf #修改配置文件
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.
[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
map to guest = Bad User
#?使用smb v1,根据需要选择,我的小米cam需要用v1才可以认上
client min protocol = NT1
server min protocol = NT1
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes
[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = @printadmin root
force group = @printadmin
create mask = 0664
directory mask = 0775
[smbshare]
#指定才可用户访问配置
path=/data2/samba/mi_cam/ #共享路径
browseable=yes
create mask=0644 #设置权限
directory mask=0755
valid users=mi-cam #可读用户
write list=mi-cam #可写用户
保存后重启服务
systemctl restart smb.service
systemctl restart nmb.service
访问和挂载
Linux访问SMB
smbclient -L //10.0.0.98/share #访问共享
Linux挂载SMB
mount.cifs //10.0.0.98/share /tmp/smbtest #将SMB共享文件夹挂载到/tmp/smbtest