contents
  1. インストールと基本設定
  2. Sambaの認証とユーザ管理
  3. ファイル共有
  4. プリンタ共有の設定
  5. ブラウジングと名前解決
    1. ノードタイプ
    2. nmblookup
    3. NetBIOSを無効
    4. ブラウジング機能関連パラメタ
  6. SambaとWindowsドメインとの連携
    1. security =
    2. security = domain
    3. security = ads
  7. Sambaによるドメインコントローラの構築
    1. PDC
    2. BDC
    3. グローバルグループ
    4. システムポリシー
    5. アカウントポリシー
    6. ユーザ権利
    7. 移動プロファイル
    8. 信頼関係
      1. SambaドメインをWindowsドメインが信頼
      2. WindowsドメインをSambaドメインが信頼
    9. LDAP認証
  8. Sambaのクライアント機能

LPIC302

インストールと基本設定

pamを有効に

configure --with-pam

インストール後にconfigureオプションを確認

smbd -b

Samba変数

%L

NetBIOS名

%U

ユーザ名

%G

プライマリグループ

%S

セクション(共有)名

%u

共有にアクセスしているユーザ名

%g

%uのプライマリグループ

%H

%uのホームディレクトリ

セクションの編集

Sambaの認証とユーザ管理

security =

share
user
server
domain
ads

security = server

password server

= SERVER1


pdbeditsmbpasswd
-L --list sambaユーザの表示
-w --smbpasswd-stylesmbpasswd形式
-a ユーザ名 --create ユーザ名sambaユーザ追加-a
-x --delete 削除-x
-i --importインポート
-e --exportエクスポート
-b --backend操作対象の認証データベース

認証データベース

passdb backend
smbpasswd:/etc/samba/smbpasswd
tdbsam:/etc/samba/smbpasswd.tdb
ldapsam:ldap://localhost:389
ldap:ldap://localhost:389

smbpasswdファイル smbuser1:UID:LANMANハッシュ:NTLMハッシュ:ユーザフラグ:最終更新時刻

ユーザフラグ

U

通常

W

コンピュータアカウント

X

無期限パスワード

I

ドメイン間信頼アカウント

H

ホームディレクトリが必要

S

サーバ信頼アカウント

D

無効、ログオンできない

N

パスワードが無い

L

ロックされている

Sambaユーザのマッピング

username map
username map script

認証データベース

smbpasswd
互換
tdbsam
拡張
ldapsam
拡張
ldapsam_compat
互換

認証データベースの移行

pdbedit -i smbpasswd:/etc/samba/smbpasswd -e tdbsam:/usr/local/samba/private/passwd.tdb
セクションの編集

ファイル共有

[share1]
  path = /home/share1
  comment = Share 1 on %H
  max connections = 10
[homes]
  browseable = no
  writeable = yes
  comment = %U's home directory
[ipc$]
  hosts allow = 192.168.1.0/255.255.255.0
  valid users = monyo @users
  invalid users = test1 test2
guest ok
guest only
force user
force group
admin users
create mask
force create mode
directory mask
force directory mode
inherit permissions
map archive
map hidden
map system
dos filetime resolution
fake directory create times
[global]
  host msdfs = yes
[dfstop]
  path = /usr/local/samba/lib/dfstop
  msdfs root = yes

# cd /usr/local/samba/lib/dfstop
# ln -s msdfs:sakura\\archive archive

表示、読み取り禁止

veto files = /.AppleDouble/.bin

アクセス権の無いファイルの表示、読み取り禁止

hide unreadable
hide unwriteable

シンボリックリンク禁止

follow symlinks = no

共有外へのアクセス禁止

wide links = no

ゴミ箱

vfs objects = recycle
recycle:repository = .trash
recycle:keeptree = yes

xlsを参照しただけでファイルの更新日が変更されないように

dos filetimes

[homes]でアクセスできるユーザを,ユーザホームの所有者のみに

valid users = %S
セクションの編集

プリンタ共有の設定

[global]
  printing = bsd
[printer1]
  printable = yes
  printer name = lp
  printing = bsd
  use client driver = Yes
  path = /tmp
[globals]
  printcap name = /etc/printcap
[printers]
  printable = yes
  comment = All printers
  browseable = no
  path = /var/spool/samba
  printing = cups
  cups options = raw
[print$]
  path = /var/lib/samba

# ls /var/lib/samba
WIN40/  W32X86/
$ net -S server -U admin rpc right grant "DOMAIN\penguin" SePrintOperatorPrivilege
セクションの編集

ブラウジングと名前解決

ノードタイプ

Bノード
ブロードキャストのみ
Pノード
WINSサーバのみ
Mノード
ブロードキャスト→WINS
Hノード
WINS→ブロードキャスト
name resolve order = lmhosts wins host bcast

nmblookup

nmblookup
-M
マスターブラウザを検索
-R
再起検索
-A
IPアドレスで指定されたマシンのNetBIOS名とMACアドレス
-U
問い合わせ先のユニキャストアドレスを指定

NetBIOSを無効

Windows2000

以降でNetBIOSを無効にしてDirect Hosting of SMBのみで構成することが可能。 Sambaでは、

disable netbios = yes

で同様の設定が可能。

ブラウジング機能関連パラメタ

workgroup
所属するワークグループ
local master
ブラウザ選定に参加するかどうか
os level
基本的な優先度
domain master
ドメインマスターブラウザとなるかどうか
preferred master
優先マスターブラウザとなるかどうか
remote announce
別のIPサブネットのブラウズリストに登録
セクションの編集

SambaとWindowsドメインとの連携

security =

share
共有単位にパスワード認証
user
ユーザ単位にパスワード認証
server
任意のSMBサーバに認証を委任
domain
NTLM認証を用いてWindowsドメインに参加
ads
Kerberosを用いてWindowsドメインに参加

security = domain

[global]
workgroup = NTDOM
security = domain
password server = NTPDC NTBDC

コンピュータアカウント+ドメイン参加

# net rpc join -U administrator -w W2003AD1 -S ADPDC

ドメイン参加のみ

# net rpc oldjoin

security = ads

[global]
workgroup = W2003AD1
realm = W2003AD1.EXAMPLE.NET
security = ads
password server = x.x.x.x
[/etc/krb5.conf]

[libdefaults]
  default_realm = W2003AD1.EXAMPLE.NET
[realms]
  W2003AD1.EXAMPLE.NET = {
    kdc = adpdc.w2003ad1.example.net
  }
[domain_realm]
  .w2003ad1.example.net = W2003AD1.EXAMPLE.NET
  w2003ad1.example.net = W2003AD1.EXAMPLE.NET
# net ads join -U Administrator

認証統合のためには、

Linuxユーザ

を別途作成する必要あり。

add user script =
/usr/sbin/useradd -m %U

を使って、Linuxユーザの作成を自動化できる。

さらに、

Winbind機構

によりLinuxユーザの作成が不要になる。

手順:

winbinddのインストール
security = domain or ads
nsswitch.confで、passwd
smb.confにてidmap uid = 10000-12000
wbinfo -t

マッピング情報の表示

net idmap dump /usr/local/samba/var/locks/winbindd_idmap.tdb

ユーザ名に\が含まれることによる誤動作を防ぐには、

winbind separator = +

あるいは、

winbind use default domain = yes

とすると、ユーザ名にドメイン名が省略される。

この方式では、マッピング情報がSambaサーバごとに管理されるため、 Sambaサーバ間で不整合が発生する可能性がある。 これを解決するには、

Idmap機構

が必要。

設定:

ldap admin dn = ...
idmap backend = ldap:ldap://127.0.0.1
ldap idmap suffix = ou=Idmap
セクションの編集

Sambaによるドメインコントローラの構築

PDC

[global]
  workgroup = SAMBADOM
  security = user
  domain logons = Yes
  passdb backend = tdbsam

  os level = 32
  domain master = auto
  preferred master = auto
  local master = yes

  wins support = yes

  add machine script = /usr/sbin/useradd -d /dev/null -s /bin/false %u

  logon home = \\%N\%U
  logon path = \\%N\%U\profile
  logon drive = H:
  logon script = 

[netlogon]
  comment   = Net Logon Share
  path      = /usr/local/samba/netlogon
  writeable = No
  write list = @administrators

[profiles]
  path = /usr/local/samba/lib/profiles
  writeable = yes
  browseable = No
  profile acls = yes

BDC

domain master = no

だけがPDCと異なる。

PDC-BDC間のSID同期

net rpc getsid SAMBADOM

認証データベースの複製

LDAPを使う

グローバルグループ

domadmというLinuxのグループを既存のDomain Adminsグローバルグループに対応づける

net groupmap modify NTgroup='Domain Admins' UNIXgroup=doomadm

システムポリシー

NT系では

NTconfig.pol

9x系では

Config.pol

NETLOGON

に置く。

アカウントポリシー

pdbedit -P アカウントポリシー [-C ポリシーの値]
maximum password age
minimum password age
min password length
password history
bad lockout attempt
lockout duration
reset count minuts
disconnect time
user must logon to change password

ユーザ権利

enable privildeges = yes

をセットすることで、

net rpc right 'SAMBADOM\monyo' SeMachineAccountPrivilege

によりユーザ権利を設定することができる

移動プロファイル

信頼関係

SambaドメインをWindowsドメインが信頼

  • 信頼関係用のLinuxユーザを作成、Sambaユーザを作成
useradd -s /bin/false -d /dev/null w2003ad1$
net rpc trustdom add w2003ad1 trustpasswd -U user%passwd
  • この後Windows側(w2003ad1)で、信頼関係締結処理。

WindowsドメインをSambaドメインが信頼

  • Windows側でSambaを信頼
  • 信頼関係を確立
net rpc trustdom establish w2003ad1

LDAP認証

[slapd.conf]
include  /etc/ldap/shema/core.schema
include  /etc/ldap/shema/cosine.schema
include  /etc/ldap/shema/nis.schema
include  /etc/ldap/shema/inetorgperson.schema
include  /etc/ldap/shema/samba.schema

database  ldbm

suffix  "dc=sample,dc=local"

directory  "/var/lib/ldap"

index objectClass eq

rootdn "cn=admin,dc=samba,dc=local"
rootpw damedame

access to attrs=userPassword
  by dn="cn=admin,dc=samba,dc=local" write
  by anonymous auth
  by self write
  by * none

access to attrs=sambaLMPassword,sambaNTPassword
  by dn="cn=admin,dc=samba,dc=local" write
  by * none

access to *
  by dn="cn=admin,dc=samba,dc=local" write
    by * read

Linuxユーザの情報もLDAPに格納
{{code(/etc/ldap.conf)
BASE  dc=samba,dc=local
URI   ldap://localhost
[/etc/nsswitch.conf]
passwd: files ldap
shadow: files ldap
group:  files ldap

smbldap-toolsの設定

[smbldap_bind.conf]
masterDN="cn=admin,dc=samba,dc=local"
masterPW="damedame"
slaveDN="cn=admin,dc=samba,dc=local"
slavePw="
damedame"
[smbldap.conf]
suffix="dc=samba,dc=local"
usersdn="ou=Users,${suffix}"
computersdn="ou=Computers,${suffix}'
groupsdn="ou=Groups,${suffix}"

Sambaの設定
{{code smb.conf)

passdb backend = ldapsam:ldap://localhost:389

ldap admin dn = cn=admin,dc=samba,dc=local
ldap suffix = 
ldap user suffix =
ldap group suffix = 
ldap machine suffix =

ldap delete dn = Yes
ldap passwd sync = Yes

add machine script = /usr/local/samba/bin/smbldap-useradd -a -w "%u"
add user script = 

[netlogon]
[homes]

LDAPデータベースの初期化

smbldap-populate [-a Administrator] [-g Guest]
smbldap-passwd Administrator

運用

smbldap-useradd
smbldap-userdel
:
:
セクションの編集

Sambaのクライアント機能

Last modified: 2014-02-25 by Unknown