CentOS 7でのSambaのインストールと構成


一、紹介
            :https://www.cnblogs.com/muscleape/p/6385583.html

Samba     Linux    Microsoft         , SMB Server Message Block   ,         ,SMB     Microsoft       ,  Samba SMB        Linux   ,       Samba  。       SMB     CIFS(Common Internet File System),    Internet     ,           ,    ,  Samba         。
Samba           Linux windows              ,Samba     windows Linux       ,     Linux Linux       ,  NFS(      )       Linux Linux       ,   Samba      Linux windows         。
SMB      /       ,    Samba               ,       Samba    ,  ,   Linux        Samba   ,windows        SMB    Samba         ,  ,Samba              windows    Linux         。
Samba windows     NetBIOS  ,      Linux        ,     windows        NetBIOS  。
  Samba        ,   SMB,    NMB;SMB Samba        ,       Linux Samba    Samba        ,                     ,  SMB    ,         ,  139 TCP  ; NMB         ,   DNS     ,NMB   Linux            IP    ,  NMB      ,     IP       ,  137 138 UDP  。
  ,  Samba    IP   192.168.0.111,         SAMBA,   Windows IE                    。     Windows   Linux Samba          。
  \\192.168.0.111\      
  \\SAMBA\      
Samba          :WINS DNS  ;       ; Linux Windows         ; UNICODE        ;  CIFS   UNIX   。

二、使用評価
   samba  ,        。     samba   ,            777.    ,                  ,         。

三、システムの準備
1、ファイアウォールを閉じる(CentOS 7のデフォルトはfirewalldを使用)
systemctl stop firewalld.service 
systemctl disable firewalld.service

2、SELINUXを閉じる
    ,    :setenforce 0
    ,      /etc/selinux/config     :SELINUX=disabled,       

四、Sambaサービスのインストール
yum install -y samba

五、Sambaサービスの配置
Samba       /etc/samba/smb.conf

           

Global Settings
        Samba             ,                。

Share Definitions
                  ,            。

    :

#==================Global Settings ===================
[global]

config file = /usr/local/samba/lib/smb.conf.%m
  :config file                       。       ,     。       ,    samba     ,      samba               。  ,   PC1(   )       Samba Server           ,    /etc/samba/host/  PC1      smb.conf.pc1   ,    smb.conf   :config file = /etc/samba/host/smb.conf.%m。   PC1    Samba Server ,smb.conf.%m     smb.conf.pc1。  ,  PC1  ,     Samba      smb.conf.pc1   ,       Samba Server     smb.conf。

workgroup = WORKGROUP
  :   Samba Server            。

server string = Samba Server Version %v
  :   Samba Server    ,        ,     。 %v    Samba    。

netbios name = smbserver
  :  Samba Server NetBIOS  。    ,           DNS       。netbios name workgroup          。

interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
  :  Samba Server      ,      ,        IP  。

hosts allow = 127. 192.168.1. 192.168.10.1
  :       Samba Server    ,         。     IP  ,          。hosts deny  hosts allow     。
  :hosts allow=172.17.2.EXCEPT172.17.2.50
      172.17.2.*     ,   172.17.2.50
hosts allow=172.17.2.0/255.255.0.0
      172.17.2.0/255.255.0.0          
hosts allow=M1,M2
      M1 M2       
hosts allow=@pega
      pega          

max connections = 0
  :max connections      Samba Server       。        ,           。0     。

deadtime = 0
  :deadtime                      。     ,0  Samba Server         。

time server = yes/no
  :time server     nmdb  windows         。

log file = /var/log/samba/log.%m
  :  Samba Server                 。        %m(   ),       Samba Server              。  pc1、pc2   Samba Server,   /var/log/samba     log.pc1 log.pc2      。

max log size = 50
  :  Samba Server         ,   kB,0     。

security = user
  :      Samba Server     ,         。
1. share:    Samba Server           ,       。
2. user:Samba Server              , Samba Server             。        Samba Server   。
3. server:    Windows NT/2000 Samba Server           ,       。       ,           Windows          NT   ,   Windows NT  Samba  ,                   ,      ,Samba                 。
4. domain:     ,       (PDC)     。

passdb backend = tdbsam
  :passdb backend         。       :smbpasswd、tdbsam ldapsam。sam   security account manager(      )   。
1.smbpasswd:      smb     smbpasswd      (          )    Samba  ,            Samba   。smbpasswd     /etc/samba   ,             。
2.tdbsam:                       。      passdb.tdb,   /etc/samba   。passdb.tdb          smbpasswd –a   Samba  ,      Samba          。       pdbedit     Samba  。pdbedit        ,         。
  pdbedit –a username:  Samba  。
  pdbedit –x username:  Samba  。
  pdbedit –L:  Samba    ,  passdb.tdb     。
  pdbedit –Lv:  Samba         。
  pdbedit –c “[D]” –u username:   Samba     。
  pdbedit –c “[]” –u username:   Samba     。
3.ldapsam:       LDAP            。     LDAP  ,    “passdb backend = ldapsam:ldap://LDAP Server”

encrypt passwords = yes/no
  :         。    windows            ,         。           。

smb passwd file = /etc/samba/smbpasswd
  :    samba       。smbpasswd             。

username map = /etc/samba/smbusers
  :         ,     root  administrator、admin 。      smbusers      。  :root = administrator admin,      administrator admin        root  Samba Server,   windows     。

guest account = nobody
  :    guest   。

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
  :                Socket  ,        。

domain master = yes/no
  :  Samba              ,                   。

local master = yes/no
  :local master    Samba Server              。    no,               。       yes,     Samba Server        ,       。

preferred master = yes/no
  :  Samba Server              ,    Samba Server             。        yes ,   domain master    yes。         :    Samba Server           (   windows NT    Samba Server)           ,                         ,      。
           Samba Server,              。

os level = 200
  :  samba    os level。     Samba Server                。os level 0 255,winNT os level 32,win95/98 os level 1。Windows 2000 os level 64。     0,    Samba Server       。    Samba Server  PDC,     os level    。

domain logons = yes/no
  :  Samba Server           。                   。

logon script = %u.bat
  :     windows     ,  Samba        。     %u.bat,                。      ,       。             ,  start.bat,            start.bat,                。         [netlogon] path        。

wins support = yes/no
  :  samba       wins  。

wins server = wins   IP  
  :  Samba Server      wins     wins  。

wins proxy = yes/no
  :  Samba Server    wins    。

dns proxy = yes/no
  :  Samba Server    dns    。

load printers = yes/no
  :       Samba       。

printcap name = cups
  :            。

printing = cups
  :  Samba        。          :bsd, sysv, plp, lprng, aix, hpux, qnx

    :
#================== Share Definitions ==================
[   ]

comment =      
  :comment        ,        。

path =       
   :path           。   %u、%m           unix       Netbios ,        [homes]    。  :        home        ,   /home/share/    Linux            ,         ,  path     :path = /home/share/%u; 。                        ,               ,  ,               。  ,               ,           ,          samba           netbios    ,           ,       :path = /home/share/%m 。

browseable = yes/no
  :browseable             。

writable = yes/no
  :writable             。

available = yes/no
  :available             。

admin users =        
  :admin users           (            )。 samba 3.0 ,           “security=share” ,    。
  :admin users =david,sandy(           )。

valid users =           
  :valid users                。
  :valid users = david,@dave,@tech(              ,          “@  ”  。)

invalid users =           
  :invalid users                 。
  :invalid users = root,@bob(              。)

write list =           
  :write list                  。
  :write list = david,@dave

public = yes/no
  :public           guest    。

guest ok = yes/no
  :   “public”。

Samba    ,  testparm      smb.conf      。  testparm –v         smb.conf       。

六、使用例
1、共有ディレクトリの作成
mkdir /data/share/

2、sambaのユーザーグループとユーザーを創立する
groupadd samba
useradd -g samba -s /sbin/nologin samba

3.共有ディレクトリのユーザーグループおよび権限の変更
      :chown -R samba:samba /data/share/
    :chmod -R 777 /data/share/
  samba  :smbpasswd -a samba
  samba  :smbpasswd -e samba

4、プロファイルの作成:/etc/samb/smb.conf
[global]
    workgroup = SAMBA
    security = user

    passdb backend = tdbsam

    printing = cups
    printcap name = cups
    load printers = yes
    cups options = raw

[homes]
    comment = Home Directories
    valid users = %S, %D%w%S
    browseable = Yes
    writable = Yes
    printable = No
    #read only = No
    #inherit acls = Yes

[printers]
    comment = All Printers
    path = /var/tmp
    printable = Yes
    create mask = 0600
    browseable = No

[print$]
    comment = Printer Drivers
    path = /var/lib/samba/drivers
    write list = @printadmin root
    force group = @printadmin
    create mask = 0664
    directory mask = 0775
[shared]
    #         
    comment = Shared Directories
    #       
    path = /data/share/
    #     guest  
    public = no
    #       
    admin users = samba
    #        、  
    valid users = @samba
    #       
    browseable = yes
    #       
    writable = yes
    #       
    create mask = 0777
    directory mask = 0777
    force directory mode = 0777
    force create mode = 0777

5、sambaを起動する
service smb start    systemctl start smb.service

6、共有ディレクトリをwindowsドライブにマッピングする
①、      –>         
②、              ,  “  ”