CentOS6中直接设置全局配置段

    security = share

或者是在全局配置段添加

    map to guest = bad user 

CentOS7中由于security = share已经被废弃需要全局配置段中添加

    map to guest = bad user 

配置文件详细配置段:

    #======================= Global Settings =====================================

    workgroup = WORKGROUP  

    server string = Samba Server %v  

    netbios name = centos  

    security = user  

    map to guest = bad user  

    dns proxy = no  

#============================ Share Definitions ==============================   

    [Anonymous]  

    path = /tmp/nobody

    browsable =yes  

    writable = yes  

    guest ok = yes  

    read only = no  

配置完成后设置匿名共享目录:

    mkdir -pv /tmp/nobody

    [root@localhost samba]# chmod -R 755 /tmp/nobody

    [root@localhost samba]# chown -R nobody:nobody /tmp/nobody

    #如果使用了selinux需要设置目录的selinux标签

    [root@localhost samba]# chcon -t samba_share_t anonymous/ 

    启动samba:systemctl reload smb.service