“轻松实现Linux和Windows文件共享,只需几步配置!“
linux配置SMB文件共享服务
环境: centos8
linux客户端访问windows共享目录
linux作为客户端需要下载客户端软件
yum update -y # 更新yum
yum install samba-client # 安装smb客户端
# SMB共享账号和权限设置好,网络联通的情况下。
# 格式:smbclient smb共享目录
smbclient //192.168.0.10/music
注意: 因为我这里是windows服务器开的smb共享,因此如果是云服务器必须打开445端口才行。
linux服务器开启SMB服务供windows访问
1.关闭防火墙和selinux,不关闭可能导致端口拦截,无法访问等问题
# 关闭firewalld
systemctl stop firewalld
# 临时关闭selinux
setenforce 0
2.安装smb服务并启动
# 直接yum安装
yum install samba
# 使用systemctl 管理进程服务
systemctl start smb
# 查看smb服务状态
systemctl status smb
3.创建共享目录
# 创建共享目录
mkdir /www/public
# 修改操作权限
chown 0755 -R /www/public
4.配置smb文件 配置文件在/etc/samba/smb.conf
[global]
workgroup = WORKGROUP
security = user
map to guest = Bad User
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[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
[share]
comment = chuck_share
path = /www/emby-server/music
browseable = yes
public = yes
writable = yes
available = yes
directory mask = 0775
create mask=0644
然后重启服务,上述配置开启匿名访问,没有进行认证,建议自己个人使用。
本文由 mdnice 多平台发布