搜档网
当前位置:搜档网 › samba共享设置

samba共享设置

samba共享设置
一、安装软件包
# rpm -qa | grep samba
samba-3.6.23-33.0.1.el6.x86_64
二、修改配置文件
配置文件所在位置:/etc/samba/smb.conf
内容说明:
74 workgroup = MYGROUP #服务器所在域或组
75 server string = Samba Server Version %v //服务器描述
76
77 ; netbios name = MYSERVER #netbios名称
……
88 # logs split per machine
89 log file = /var/log/samba/log.%m //设置samba服务器共享日志
90 # max 50KB per log file, then rotate
91 max log size = 50 //设置日志最大容量
//默认samba服务器建立有两个日志文件nmbd.log、smbd.log
……
101 security = user //用户登录的安全级别
//share(共享)、server、 domain(windows server 2003 服务器域的客户端)其中user、share常用
102 passdb backend = tdbsam
…… #以下是共享的相关设置
246 #============================ Share Definitions ==============================
247
248 [homes] //共享名
249 comment = Home Directories //说明
250 browseable = no //不可列示
251 writable = yes //可以读写
252 ; valid users = %S
253 ; valid users = MYDOMAIN\%S
254
255 [printers] //共享打印机
256 comment = All Printers
257 path = /var/spool/samba //绝对路径
258 browseable = no
259 guest ok = no
260 writable = no
261 printable = yes
262
263 # Un-comment the following and create the netlogon directory for Domain Logons
264 ; [netlogon]
265 ; comment = Network Logon Service
266 ; path = /var/lib/samba/netlogon
267 ; guest ok = yes
268 ; writable = no
269 ; share modes = no
一些参数说明:
public = yes/no //是否允许匿名访问
valid users = 用户名
valid users = @组名
readonly = yes/no //只读/读写
设置目录写入权限
writable = yes/no //读写/只读
write list = 用户名、@组名
三、建立一个简单共享
1、将原来的smb.conf重命名,再新建一个smb.conf,输入如下内容:
[global]
workgroup = WORKGROUP
server string = Samba Server Version %v
[share]
comment = share
path = /mnt_array/share
public = yes
writeable = yes
browseable = yes
guest ok = yes
2、创建文件夹/mnt_array/share,并修改权限为777
# mkdir /mnt_array/share -p
# chmod -R 777 /mnt_array/share
3、重启smb服务
# service smb restart

# /etc/init.d/smb restart
4、在防火墙中放开samba相关服务或直接关闭防火墙
关闭防火墙
# service iptables stop (立即生效)
# chkconfig iptables off (重启后生效)
配置防火墙中开放samba相关服务
# setup -> 防火墙配置 -> 定制 -> 选中Samba、Samba客户端 -> 关闭 -> 确定 ……
用命令方式放开samba相关端口
#iptables -I RH-Firewall-1-INPUT 5 -m state

--state NEW -m tcp -p tcp --dport 139 -j ACCEPT
#iptables -I RH-Firewall-1-INPUT 5 -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
#iptables -I RH-Firewall-1-INPUT 5 -p udp -m udp --dport 137 -j ACCEPT
#iptables -I RH-Firewall-1-INPUT 5 -p udp -m udp --dport 138-j ACCEPT
#iptables -save
#service iptables restart
5、设置selinux
直接关闭
#setenforce 0
修改配置文件,使selinux在重启后也关闭
#vi /etc/selinux/config
将SELINUX=enforcing修改为SELINUX=disabled
放开相关权限
#setsebool -P samba_enable_home_dirs on
#setsebool -P samba_export_all_rw on
完成后再执行:
#getsebool -a | grep samba
6、将samba服务设为开机启动
查看当前状态
#chkconfig --list | grep smb
设置在3、5级别上自动运行smb服务(3:有网络连接的多用户命令行模式;5:带图形界面多用户模式)
#chkconfig --level 35 smb on
四、建立多用户控制
1、新建用户,用于访问专用共享
#useradd smb_user1
#passwd smb_user1
2、将新建用户加入到smb,并设置该用户smb中的密码
#smbpasswd -a smb_user1
3、建立需要共享的文件夹,并设置相关权限
#mkdir /mnt_array/smbuser1_share
#chown smb_user1:smb_user1 /mnt_array/smbuser1_share
#chmod 700 /mnt_array/smbuser1_share
注:如果需要设置为一个组内的用户都可以访问,则需要把700改为770
4、编辑/etc/samba/smb.conf文件
[smbuser1]
path = /mnt_array/smbuser1_share
writable = yes
public = no
vaild users = smb_user1
注:[global]中的security参数应设为user
[global]
……
security = user
……
5、重启smb服务
service smb restart

测试配置参数:#testparm
例:
[root@TestLinux /]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[smbuser1]"
Unknown parameter encountered: "vaild users"
Ignoring unknown parameter "vaild users"
Processing section "[smbuser2]"
Unknown parameter encountered: "vaild users"
Ignoring unknown parameter "vaild users"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
client signing = required
idmap config * : backend = tdb
cups options = raw
[homes]
comment = Home Directories
read only = No
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
print ok = Yes
browseable = No
[smbuser1]
path = /mnt_array/smbuser1_share
read only = No
[smbuser2]
path = /mnt_array/smbuser2_share
read only = No
[root@TestLinux /]#


相关主题