CentOS6.2samba服务器搭建

匿名访问
1. yum -y install samba samba-common
2. cd /etc/samba
vim smb.conf
# 1). 先设定好服务器整体环境方面的参数
[global]
# 与主机名有关的设定信息
workgroup = vbirdhouse
netbios name = vbirdserver
server string = This is vbird's samba server

# 与语系方面有关的设定项目喔,为何如此设定请参考前面的说明
unix charset = utf8
display charset = utf8
dos charset = cp950

# 与登录文件有关的设定项目,注意变量 (%m)
log file = /var/log/samba/log.%m
max log size = 50

# 这里才是与密码有关的设定项目哩!
security = share

# 修改一下打印机的加载方式,不要加载啦!
load printers = no

# 2). 分享的资源设定方面:主要得将旧的批注,新的加入!
# 先取消 [homes], [printers] 的项目,然后针对 /tmp 的设定,可浏览且可写入喔
[temp] <==分享资源名称 comment = Temporary file space <==简单的解释此资源 path = /tmp <==实际 Linux 分享的目录 writable = yes <==是否可写入?在此例为是的 browseable = yes <==能不能被浏览到资源名称 guest ok = yes <==单纯分享时,让用户随意登入的设定值 3. service smb start service smb start

解决samba和SELINUX 冲突

在使用Samba进行建立Window与Linux共享时,要是不能访问,出现“您可能没有权限使用网络资源”,

那就是SELinux在作怪了
要是想让共享目录能访问,可以使用命令
#setenforce 0
暂时停掉SELinux
使用
#setenforce 1
启用SELinux

有关SELinux 在系统中的作用就不讲了,另外一种方法可以不用关闭SELinux.以下命令将允许这个权限:
setsebool -P samba_enable_home_dirs=1

若SElinux啟用中,在Windows檔案總管無法連到 Samba 所分享出來的目錄時,
在Linux 中,可執行下列指令:
setsebool -P samba_enable_home_dirs on

參考文件: /etc/samba/smb.conf
#---------------
# SELINUX NOTES:
# 分享群組
# If you want to use the useradd/groupadd family of binaries please run:
# setsebool -P samba_domain_controller on
#
# 分享home目錄
# If you want to share home directories via samba please run:
# setsebool -P samba_enable_home_dirs on
#
# If you create a new directory you want to share you should mark it as
# "samba-share_t" so that selinux will let you write into it.
# Make sure not to do that on system directories as they may already have
# been marked with othe SELinux labels.
#
# Use ls -ldZ /path to see which context a directory has
#
# Set labels only on directories you created!
# To set a label use the following: chcon -t samba_share_t /path
#
# If you need to share a system created directory you can use one of the
# following (read-only/read-write):
# setsebool -P samba_export_all_ro on
# or
# setsebool -P samba_export_all_rw on
#
# If you want to run scripts (preexec/root prexec/print command/...) please
# put them into the /var/lib/samba/scripts directory so that smbd will be
# allowed to run them.
# Make sure you COPY them and not MOVE them so that the right SELinux context
# is applied, to check all is ok use restorecon -R -v /var/lib/samba/scripts
#
#--------------
#