2.4 配置smb.conf
linux:/ # vi /etc/samba/smb.conf
修改【global】下的security=user,说明:设置用户访问samba server的验证方式,一共有四种验证方式。
a. share:用户访问samba server不需要提供用户名和密码,安全性较低。
b. user:samba server共享目录只能被授权的用户访问,由samba server负责检查账号和密码的正确性。账号和密码要在samba server中建立。
c. server:依靠其他windows NT/2000 或samba server来验证用户的账号和密码,是一种代理验证。此种安全模式下,系统管理员可以把所有的windows用 户和口令集中到一个NT系统上,使用windows NT进行samba认证,远程服务器可以自动认证全部用户和口令,如果认证失败,samba将使用用户级安全模式作为替代的方式。
d. domain:域安全级别,使用主域控制器(PDC)来完成认证。
在2.2步之后,smb.conf文件下面自动添加了【share】段名。
[share]
.........
Writable = Yes
Browsable = Yes
Valid users =smb //由于security 为user则需要写上允许的用户名
Guest ok = on //打开guest用户
修改完成后保存文件。
2.5 重启samba服务器
linux:/ # /etc/rc.d/smb restart
3. windows访问samba服务器
运行里输入linux IP,输入用户名和密码。
若是打开了防火墙需要把smb添加到trust 列表中。
可以通过setup命令进入配置
可以直接通过iptable来配置访问(这个更安全)
若是SElinux设置为enforcing
则设置如下:
//以下文字位于/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
#
# If you want to share home directories via samba please run:
# setsebool -P samba_enable_home_dirs on //设置SElinux 策略允许用户访问自己的主目录
##//为设置为共享的文件夹设置SELinux安全上下文(context)
# 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
通过以上设置就可以在开启防火墙、SElinux的情况下正常访问基于REHL的samba服务器
