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 = SAMBAsecurity = usersmb ports = 10086passdb backend = tdbsamprinting = cupsprintcap name = cupsload printers = yescups options = raw[homes]comment = Home Directoriesvalid users = %S, %D%w%Sbrowseable = Noread only = Noinherit acls = Yes[printers]comment = All Printerspath = /var/tmpprintable = Yescreate mask = 0600browseable = No[print$]comment = Printer Driverspath = /var/lib/samba/driverswrite list = @printadmin rootforce group = @printadmincreate mask = 0664directory mask = 0775[Records]comment = Shared Folder with username and passwordpath = /home/Recordvalid users = sharepublic = yeswritable = noprintable = nocreate mask = 0755directory mask = 0755
启动服务
systemctl start smb
开放端口
firewall-cmd --zone=public --add-port=10086/tcp --permanentfirewall-cmd --zone=public --add-port=10086/udp --permanentfirewall-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