yum安装
yum -y install samba*
安装完成后,目录结构如下
/etc/samba/smb.conf #samba 服务的主要配置文件
/etc/samba/lmhosts #samba 服务的域名设定,主要设置 IP 地址对应的域名,类似 linux 系统的 / etc/hosts
/etc/samba/smbusers #samba 服务设置 samba 虚拟用户的配置文件
/var/log/samba #samab 服务存放日志文件
/var/lib/samba/private/{passdb.tdb,secrets.tdb} # 存放 samba 的用户账号和密码数据库文档
配置
创建共享用户
useradd share
创建smb用户名密码,使用之前创建的用户
smbpasswd -a share 回车后,配置密码
vim /etc/samba/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
smb ports = 10086
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
[Records]
comment = Shared Folder with username and password
path = /home/Record
valid users = share
public = yes
writable = no
printable = no
create mask = 0755
directory mask = 0755
启动服务
systemctl start smb
开放端口
firewall-cmd --zone=public --add-port=10086/tcp --permanent
firewall-cmd --zone=public --add-port=10086/udp --permanent
firewall-cmd --reload
远程挂载
mount -t cifs -o username=用户名,password=用户名密码,port=10086 //samba服务器Ip地址/共享目录配置项名称 挂载地址
如:mount -t cifs -o username=share,password=密码,port=10086 //1.1.1.1/Records radio