samba服务笔记


首先查看当前计算机是否安装这samba,我的没有安装,我是直接yum install samba*安装
本次要做的要求 是根目录下public这个文件夹的文件所有用户都可以访问,/home/xiaoshou这个文件夹只允许xiaoshou用户看以及更改,最后是指定网段可以访问指定文件夹。

[root@localhost ~]# rpm -qa|grep samba
samba-3.0.33-3.39.el5_8
samba-common-3.0.33-3.39.el5_8
samba-client-3.0.33-3.39.el5_8
system-config-samba-1.2.41-5.el5

首先大概的看下samba的配置文件
[root@localhost ~]# grep -v ^# /etc/samba/smb.conf |grep -v ^$|grep -v "^;" 
[global]
        workgroup = MYGROUP  //设置samba服务器所在的工作组的名字,默认设置为 MYGROUP
        server string = Samba Server Version %v
        # logs split per machine
        # max 50KB per log file, then rotate
        security = user  //设置samba服务器的默认安全级别为user,表示需要经过samba服务器的用户认证才能够访问服务器中的资源
        passdb backend = tdbsam
        # the login script name depends on the machine name
        # the login script name depends on the unix user used
        # disables profiles support by specifing an empty path
        load printers = yes
        cups options = raw
        #obtain list of printers automatically on SystemV
[homes]
        comment = Home Directories
        browseable = no
        writable = yes
[printers]
        comment = All Printers
        path = /var/spool/samba
        browseable = no
        guest ok = no
        writable = no
        printable = yes


首先创建public这个目录
[root@localhost /]# mkdir public

修改下权限
[root@localhost /]# chown nobody.nobody /public/

[root@localhost /]# ls -l|grep pub
drwxr-xr-x   2 nobody nobody  4096 05-17 12:25 public


因为上边的比较麻烦 ,我就直接在最后变添加
[root@localhost /]# vi /etc/samba/smb.conf
最后添加
[public]
        path=/public
        public=yes
        only guest=yes
        writable=yes

对smb.conf文件配置的测试
[root@localhost /]# testparm
Load smb config files from /etc/samba/smb.conf
Processing section "[homes]"
Processing section "[printers]"
Processing section "[public]"
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
        passdb backend = tdbsam
        cups options = raw

[homes]
        comment = Home Directories
        read only = No
        browseable = No

[printers]
        comment = All Printers
        path = /var/spool/samba
        printable = Yes
        browseable = No

[public]
        path = /public
        read only = No
        guest only = Yes
        guest ok = Yes

OK,没问题 ,可以启动了,但愿不出问题,
启动samba  也就是smb服务
[root@localhost /]# service smb start
启动 SMB 服务:[确定]
启动 NMB 服务:[确定]

OK,启动成功,但是还是没法访问,一直提示帐号密码有问题,判断没有nobody此用户
[root@localhost /]# useradd nobody
useradd:用户 nobody 已存在

重要的一步发现了,没有建立samba的nobody用户帐号

[root@localhost /]# smbpasswd -a nobody
New SMB password:
Retype new SMB password:
Added user nobody.

现在访问,没有问题了。


现在开始弄第二个要求,让xiaoshou只看到销售的文件夹
还是直接在配置文件,最后变添加
[root@localhost /]# vi /etc/samba/smb.conf

[xiaoshou]
        comment = for xiaoshou users
        path = /home/xiaoshou
        valid users = xiaoshou
        read only = No

只需要这样设置 就行了,让xiaoshou这个用户访问/home/xiaoshou这个文件夹  首先必须要有xiaoshou这个用户,并且samba也建立了xiaoshou此用户

 [zhiding]
 comment = ceshishare                                         
 path =  /home/zhiding                                    
 public = yes
 guest ok = yes                                                           
 writable = yes
 read only = no
 force create mask=0777
 browseable=yes
 allow hosts = 192.168.0.20

还是使用nobody用户访问 ,但是只允许192.168.0.20 访问。

posted @ 2012-05-22 22:59  kingtigerhu  阅读(214)  评论(0编辑  收藏  举报