摘要
1、linux下安装samba服务
2、配置samba服务
一、 安装环境
1、 Centos
yum install samba
2、 Ubuntu
apt install samba
apt update
二、编辑配置文件
vi /etc/samba/smb.conf
[global]
workgroup = SAMBA
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
# browseable = no
# writable = yes
# valid users = %S
#[printers]
# comment = All Printers
# path = /var/spool/samba
# browseable = no
# guest ok = no
# writable = no
# printable = yes
#[prints$]
# comment = Printer Drivers
# path = /var/lib/samba/drivers
# write list = @printadmin root
# force group = @printadmin
# create mask = 0664
# directory mask = 0775
[home]
comment = home
path = /home
public = yes
writable = yes
browseable = yes
guest ok = yes
配置说明:
旧版本
#security = user // 注释掉原来的user
security = share // 变成共享的
新版本
security = user
map to guest = Bad User //加上这行
新版本用方式1会启动失败。
三、启动服务
systemctl restart smb
四、其他问题
1、如果出现资源管理器无法打开samba地址
关闭防火墙或开启防火墙端口白名单
systemctl stop firewalld
systemctl diabled firewalld
2、如果出现资源管理器无法写入
暂时关闭selinux
setenforce 0
永久关闭selinux(重启生效)
vi /etc/selinux/config
#SELINUX=enforcing // 注释该行
SELINUX=disable //加入这行
3、无论怎么修改都需要输入验证
sudo smbpasswd -a root
添加root(随意使用已有的用户名),再填入密码,使用该用户登录
五、使用
在资源管理器打开 \\192.168.*.*\ 就能打开已开启的samba服务