Samba服务器配置
CentOS 6.5_x64
========================
1 保证网络连通性
[root@localhost ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:56:17:70
inet addr:192.168.1.166 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe56:1770/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:132 errors:0 dropped:0 overruns:0 frame:0
TX packets:78 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13048 (12.7 KiB) TX bytes:10173 (9.9 KiB)
Interrupt:18 Base address:0x2000
[root@localhost ~]# service iptables stop
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:清除防火墙规则: [确定]
iptables:正在卸载模块: [确定]
[root@localhost ~]# chkconfig iptables off
[root@localhost ~]# setenforce 0
----------------------------------------
2 安装samba服务器软件包组(本地YUM源方式安装)
2.1 挂载光盘
[root@localhost ~]# mount /dev/cdrom /media/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir aaa
[root@localhost yum.repos.d]# mv *.repo aaa/
[root@localhost yum.repos.d]# cp aaa/CentOS-Media.repo ./
[root@localhost yum.repos.d]# ls
aaa CentOS-Media.repo
[root@localhost yum.repos.d]# vi CentOS-Media.repo
...以上内容省略..
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/ //修改此处,指明YUM仓库文件的路径
gpgcheck=1 //表明启用gpg校验值验证
enabled=1 //将此处的0改为1,表明启用本地YUM源安装
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
------------------------------------------------------
2.2 使用yum命令安装
[root@localhost ~]# yum -y install samba //安装samba
====
3 :构建可匿名访问的共享
3.1 修改配置文件
[root@localhost ~]# cd /etc/samba/
[root@localhost samba]# cp smb.conf smb.conf.bak
[root@localhost samba]# vi smb.conf
..以上省略..
101 security = share //将user改为share,启用匿名共享
..以上省略
289 [guangpan]
290 comment = cdromcdrom
291 path = /media
292 public = yes
293 read only = yes
294 [benet]
295 comment = share files
296 path = /aaa
297 public = yes
298 writable = yes
====================================
[root@localhost samba]# mkdir /aaa
[root@localhost samba]# chmod 777 /aaa
3.2 测试配置文件的正确性
[root@localhost samba]# 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 "[guangpan]"
Processing section "[benet]"
WARNING: The security=share option is deprecated
Loaded services file OK. //出现此行表明配置文件没有错误
..以下省略..
---------------------------------------------
3.3 启动samba服务器
[root@localhost samba]# service smb restart
关闭 SMB 服务: [确定]
启动 SMB 服务: [确定]
[root@localhost samba]# chkconfig smb on
[root@localhost samba]# chkconfig smb --list
smb 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
----------------------------------------------------
3.4 检测
==================
4:构建需用户验证的共享
4.1 建立samba用户数据库文件
[root@localhost aaa]# useradd vina
[root@localhost aaa]# pdbedit -a -u vina
new password:
retype new password:
Unix username: vina
===================
[root@localhost aaa]# pdbedit -L
vina:500:
[root@localhost aaa]# pdbedit -vL vina
Unix username: vina
NT username:
Account Flags: [U ]
User SID: S-1-5-21-2552859447-2060033353-296718525-1000
Primary Group SID: S-1-5-21-2552859447-2060033353-296718525-513
Full Name:
Home Directory: \\localhost\vina
HomeDir Drive:
Logon Script:
Profile Path: \\localhost\vina\profile
Domain: LOCALHOST
Account desc:
Workstations:
Munged dial:
Logon time: 0
Logoff time: 三, 06 2月 2036 23:06:39 CST
Kickoff time: 三, 06 2月 2036 23:06:39 CST
Password last set: 四, 09 7月 2015 10:21:00 CST
Password can change: 四, 09 7月 2015 10:21:00 CST
Password must change: never
Last bad password : 0
Bad password count : 0
Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
============================================
4.2设置用户访问授权
4.2.1 新建测试目录与测试用户
[root@localhost aaa]# useradd tom
[root@localhost aaa]# useradd lisi
[root@localhost aaa]# pdbedit -a -u tom
[root@localhost aaa]# pdbedit -a -u lisi
[root@localhost aaa]# mkdir /xing/aaa
[root@localhost aaa]# chmod 777 /xing/aaa
4.2.2 修改 smb.conf 配置文件,添加名为 aaa 的共享目录
[root@localhost aaa]# vi /etc/samba/smb.conf
以上省略...
101 security = user //此处改为user ,表示启用USER安全级别
在最后一行下追加如下内容
299 [tools]
300 comment = You can get software tools from here.
301 path = /xing/aaa
302 public = no
303 read only = yes
304 valid users = tom, lisi
305 write list = lisi
306 directory mask = 0755
307 create mask = 0644
4.2.3 重新加载 smb.conf 文件
[root@localhost aaa]# service smb reload
重新载入 smb.conf 文件: [确定]
本文出自 “啊兴” 博客,请务必保留此出处http://xing5186.blog.51cto.com/2947464/1672961
原文地址:http://xing5186.blog.51cto.com/2947464/1672961