Chinaunix首页 | 论坛 | 博客
  • 博客访问: 70331
  • 博文数量: 12
  • 博客积分: 266
  • 博客等级: 二等列兵
  • 技术积分: 181
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-27 16:20
文章分类

全部博文(12)

文章存档

2012年(12)

我的朋友

分类: LINUX

2012-11-22 10:05:38

samba配置实例需求:
       搭建办公室文件共享系统
,有以下用户方:
       管理人员(licheng)
       开发人员(devA,devB)
       系统人员(sysA,sysB)
       行政人员(mmA,mmB,mmC,mmD,mmE)
       财务人员(moneyA)
       工程人员(engineerA,engineerB)
      
       实现功能:
       1.licheng能管理所有的文件共享
       2.每个部门都一个供自己部门的人员进行读写的文件共享目录,对其他部门隐私
       3.有一个文件共享目录供所有部门共享


服务器环境:
       Ubuntu 12.10
       3.5.0-18-generic
       普通PC硬件


实现方案:
      1.安装samba软件

利用apt-get安装

  1. # apt-get install samba
        2.创建相应三无用户和组,并设置权限

点击(此处)折叠或打开

  1. root@licheng-G41D3:~# for gg in dev syser mm money engineer  #创建相应组用户
  2. > do
  3. > groupadd $gg
  4. > done

  5. useradd -g dev -s /sbin/nologin devA    #把对应的用户加到组用户中
  6. useradd -g dev -s /sbin/nologin devB


  7. root@licheng-G41D3:~# mkdir /smbdata/
  8. root@licheng-G41D3:~# chown licheng.licheng /smbdata  #设置目录权限


  9. root@licheng-G41D3:~# mkdir /smbdata/mm/             
  10. root@licheng-G41D3:~# chown licheng.mm /smbdata/mm  #设置目录组权限
  11. root@licheng-G41D3:~# chmod 770 /smbdata/mm/

  12. root@licheng-G41D3:~# mkdir /smbdata/dev/
  13. root@licheng-G41D3:~# chown licheng.dev /smbdata/dev
  14. root@licheng-G41D3:~# chmod 770 /smbdata/dev/

其他用户和组都进行类似设置





        3.配置smb.conf

编辑/etc/samba/smb.conf

  1. [global]
  2.    workgroup = WORKGROUP
  3.    server string = %h server (Samba, Ubuntu)
  4.    dns proxy = no
  5.    log file = /var/log/samba/log.%m
  6.    max log size = 1000
  7.    syslog = 0
  8.    panic action = /usr/share/samba/panic-action %d
  9.    security = user
  10.    encrypt passwords = true
  11.    passdb backend = tdbsam

  12. [admin]
  13.    comment = sa
  14.    path = /smbdata
  15.    valid users = licheng
  16.    create mask = 0664
  17.    writeable = yes
  18.    browseable = no
  19.    public=no

  20. [开发组]
  21.    comment = deverloper
  22.    path = /smbdata/dev/
  23.    valid users = licheng,@dev   #--@dev代表组用户
  24.    create mask = 0664
  25.    writeable = yes
  26.    browseable = yes
  27.    public=yes

  28. [系统组]
  29.    comment = systemadmin
  30.    path = /smbdata/sys/
  31.    valid users = @syser,licheng
  32.    create mask = 0664
  33.    writeable = yes
  34.    browseable = yes
  35.    public=yes

  36. [行政组]
  37.    comment = mm
  38.    path = /smbdata/mm/
  39.    valid users = licheng,@mm
  40.    create mask = 0664
  41.    writeable = yes
  42.    browseable = yes
  43.    public=yes

  44. [财务组]
  45.    comment = money
  46.    path = /smbdata/money/
  47.    valid users = @money,licheng
  48.    create mask = 0664
  49.    writeable = yes
  50.    browseable = yes
  51.    public=yes

  52. [工程组]
  53.    comment = engineer
  54.    path = /smbdata/engineer/
  55.    valid users = @engineer,licheng
  56.    create mask = 0664
  57.    writeable = yes
  58.    browseable = yes
  59.    public=yes

  60. [分享组]
  61.    comment = share
  62.    path = /smbdata/share/
  63.    create mask = 0664
  64.    browseable = yes
  65.    public=yes
  66.    read only = no
  67.    guest ok = yes
            4. 通过pdbedie配置tdbsam类型的各部门帐号密码

pdbedit进行设置帐号密码

  1. root@licheng-G41D3:~# pdbedit -a devA
  2. new password:
  3. retype new password:
  4. Unix username: devA
  5. NT username:
  6. Account Flags: [U ]
  7. User SID: S-1-5-21-732587476-2757912329-675466344-1000
  8. Primary Group SID: S-1-5-21-732587476-2757912329-675466344-513
  9. Full Name:
  10. Home Directory: \\licheng-g41d3\deva
  11. HomeDir Drive:
  12. Logon Script:
  13. Profile Path: \\licheng-g41d3\deva\profile
  14. Domain: LICHENG-G41D3
  15. Account desc:
  16. Workstations:
  17. Munged dial:
  18. Logon time: 0
  19. Logoff time: never
  20. Kickoff time: never
  21. Password last set:, 22 11月 2012 16:07:22 CST
  22. Password can change:, 22 11月 2012 16:07:22 CST
  23. Password must change: never
  24. Last bad password : 0
  25. Bad password count : 0
  26. Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
            设置完成后可以通过pdbedit -L 进行查看已设置的帐号

查看tdbsam类型帐号

  1. root@licheng-G41D3:~# pdbedit -L
  2. devA:1001:
  3. sysA:1003:
  4. sysB:1004:
  5. devB:1002:
  6. licheng:1000:licheng
  7. mmA:1005:
  8. mmB:1006:
  9. mmC:1007:
  10. mmD:1008:
  11. mmE:1009:
  12. moneyA:1010:
  13. engineerA:1011:
  14. engineerB:1012:
           5.启动samba
  1. root@licheng-G41D3:~# /etc/init.d/nmbd start
  2. Rather than invoking init scripts through /etc/init.d, use the service(8)
  3. utility, e.g. service nmbd start

  4. Since the script you are attempting to invoke has been converted to an
  5. Upstart job, you may also use the start(8) utility, e.g. start nmbd
  6. nmbd start/running, process 7796
  7. root@licheng-G41D3:~# /etc/init.d/smbd start
  8. Rather than invoking init scripts through /etc/init.d, use the service(8)
  9. utility, e.g. service smbd start

  10. Since the script you are attempting to invoke has been converted to an
  11. Upstart job, you may also use the start(8) utility, e.g. start smbd
  12. smbd start/running, process 7811

           6.检测. 当在windows上进行\\检测的时候,如果你已经连接了一个帐号密码,要测试第二个的时候会报以下错误:
      "不允许一个用户使用一个以上用户名与一个服务器或共享资源的多重连接......."
      是因为windows的机制造成的,可以用以下命令后再做第二个帐号检测:
  1. net use * /del /y
         
           7.如果有新的用户加入,只要将这个用户的组权限设置到对应的部门目录即可.











         
阅读(2295) | 评论(0) | 转发(0) |
0

上一篇:linux利用pyodbc连接sqlserver

下一篇:没有了

给主人留下些什么吧!~~