linux文件共享;centos;samba;wsdd2

55gY 1,600 0

需求

需一台服务器作为文件共享使用
要求:多用户,权限控制,白嫖[aru_45]

环境

系统:Centos7
架构:x86_64

安装

#安装samba
yum install samba samba-client samba-common -y

NetBios

由于WIN10安全性的原因,你可能不能用主机名\\dav这样的方式访问这个共享,可以选择安装wsdd2来实现NetBios
需要先配置/etc/samba/smb.conf配置文件[global]里面添加netbios name = dav

#安装gcc编译环境
yum -y install gcc automake autoconf libtool make
#下载并解压wsdd2
tar -zxvf <(curl -Ls https://github.com/Netgear/wsdd2/archive/1.8.7.tar.gz)
#进入wsdd目录
cd wsdd2-1.8.7
#编译wsdd
make CFLAGS=-std=gnu99
#复制编译好的文件到sbin
cp wsdd2 /usr/sbin/
#设置服务项wsdd2.service
vim /lib/systemd/system/wsdd2.service

[Unit]
Description=WSD/LLMNR Discovery/Name Service Daemon
BindsTo=smb.service

[Service]
ExecStart=/usr/sbin/wsdd2
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
DynamicUser=true
AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN
PrivateTmp=true
PrivateDevices=true
ProtectSystem=full
ProtectHome=true

[Install]
WantedBy=multi-user.target

#重载服务
systemctl daemon-reload
#服务设置开机启动
systemctl enable wsdd2
#启动wsdd2
systemctl start wsdd2

常用命令

##重启服务
service smb restart
##编辑配置文件
vi /etc/samba/smb.conf
##验证配置文件
testparm /etc/samba/smb.conf
##查看所有用户组
cat /etc/group
##查看所有用户
cat /etc/passwd
##创建用户组
groupadd 组
##创建用户并添加到组
useradd -g 组 用户名
##添加共享用户
smbpasswd -a 用户名
##创建文件夹并设置权限
mkdir -p /home/dav/bak/
chmod -R 0777 /home/dav/bak/
##关闭防火墙
systemctl disble firewalld
setenforce 0
getenforce

smb.conf配置文件

[global]
   #工作组  
   workgroup = WORKGROUP 
   #服务器备注
   server string = dav 
   #主机名 \\dav
   netbios name = dav
   #日志文件
   log file = /etc/samba/stdout
   #日志大小
   max log size = 1000
   realm = dav                      
   dns proxy = no     
   pam password change = yes 
   #guest用户映射,有效值是"Never"、"Bad User"、"Bad Password"。                                     
   map to guest = bad user                                       
   usershare allow guests = yes 
   #建立文件时所给的权限                                 
   create mask = 0664                                            
   force create mode = 0664
   #建立目录时所给的权限                                      
   directory mask = 0777                                         
   force directory mode = 0775 
   #指定存取资源时须以此设定的使用者进入才能存取(用户名/@组名)                                  
   force user = "root"
   #指定存取资源时须以此设定的群组使用者进入才能存取(用户名/@组名)
   force group = "root"
   follow symlinks = yes 
   #最大连接数目0代表无限制
   max connections = 0
   #决定是否装载printcap文件中所有的打印机以供浏览                                        
   load printers = no                                            
   printing = bsd
   printcap name = /dev/null                                     
   disable spoolss = yes                                         
   strict locking = no                                           
   aio read size = 0                                             
   aio write size = 0                                            
   vfs objects = catia fruit recycle streams_xattr               
   recycle:keeptree = yes                                        
   recycle:maxsize = 0                                           
   recycle:repository = .deleted                                 
   recycle:versions = yes
   #显示中文名
   unix charset = UTF-8
   dos charset = cp936
   #共享文件显示中文名
   #client code page = 939
   # Security
   client ipc max protocol = SMB3                                
   client ipc min protocol = SMB2_10                             
   client max protocol = SMB3                                    
   client min protocol = SMB2_10                                 
   server max protocol = SMB3                                    
   server min protocol = SMB2_10                                 
   # Time Machine
   fruit:delete_empty_adfiles = yes                              
   fruit:time machine = yes                                      
   fruit:veto_appledouble = no                                   
   fruit:wipe_intentionally_left_blank_rfork = yes               
   # Other   
   ntlm auth = yes                                               
   sync always = yes
   #共享是否可见
   browseable = yes
   #游客可见
   guest ok = yes
   #侦听 NetBIOS
   #pid directory = /var/run
   #unix extensions = yes
   #smb ports = 139
   #wins support = yes
   #wins proxy = yes 
   #dgram port = 138
   #nbt port = 137 
   #wins server = 192.168.8.244
   #winsdb:local_owner = 2
   #关闭netbios
   disable netbios = yes 
   #hostname lookups = yes 
[bak]                                          
    #目录
    path = /bak/金蝶                     
    #共享是否可见
    browseable = no
    #游客                             
    guest ok = no                            
    #可读写白名单@root为组;root为用户
    write list = "@root" "bak"
[guest]                                          
    #目录
    path = /dav/公共文件
    #可读写白名单@root为组;root为用户
    write list = "@root"                         
[pmc]                                            
    #目录
    path = /dav/计划部   
    #可读写白名单@root为组;root为用户
    write list = "@root"

本站资源来自互联网收集,仅供用于学习和交流,请勿用于商业用途。如有侵权、不妥之处,请联系站长并出示版权证明以便删除。敬请谅解!

发表评论 取消回复
表情 图片 链接 代码