「How to build Samba PDC (squeeze)」の版間の差分
細 (→PAM の手動設定) |
|||
(同じ利用者による、間の5版が非表示) | |||
1行目: | 1行目: | ||
= Get release image for Debian GNU/Linux = |
= Get release image for Debian GNU/Linux = |
||
[http://www.debian.org/distrib/netinst#smallcd small CD] |
Download [http://www.debian.org/distrib/netinst#smallcd small CD] |
||
以下のイメージを入手。 |
|||
* debian-6.0.0-i386-netinst.iso |
* Actually use debian-6.0.0-i386-netinst.iso |
||
= Build VMware Virtual Machine = |
= Build VMware Virtual Machine = |
||
== How to create VM == |
|||
== 仮想マシン作成の手順 == |
|||
Run the Virtual Machine Wizard |
|||
仮想マシン作成ウィザードで以下を指定 (VMware Workstation 7.1.1 日本語 |
|||
版環境で構築) |
|||
* Select ''Custom'' |
|||
* ''カスタム'' を選択 |
|||
* |
* Select ''Workstation 5'' as Hardware compatibility |
||
** Do not check ''ESX Server'' |
|||
* ジョンで動作するように) |
|||
* Select ''Linux'' as guest OS |
|||
** ''ESX Server'' はチェックしない |
|||
* Select ''Debian 5'' as version |
|||
* ゲストOSとして ''Linux''を選択 |
|||
* Set ''sambapdc'' as VM's name |
|||
* バージョンとして ''Debian 5'' を選択 |
|||
* Set ''1'' as number of CPU |
|||
* 仮想マシン名として ''sambapdc'' を指定 |
|||
* Set ''256MB'' as available memory |
|||
* プロセッサ数として ''1'' を指定 |
|||
* Leave ''NAT'' at Network Connection |
|||
* メモリ容量を ''256MB'' に変更 |
|||
* Leave ''LSI Logic'' at I/O controller type |
|||
* ネットワーク接続を ''NAT を使用'' のまま |
|||
* Select ''Create new virtual disk'' |
|||
* I/O コントローラタイプは''LSI Logic'' のまま |
|||
* Select ''SCSI'' as type of virtual disk and leave other settings |
|||
* ''仮想ディスクの新規作成''を選択 |
|||
* 仮想ディスクタイプとして ''SCSI'' を選択 |
|||
* ディスクサイズほかは規定値のまま(8.0 GB / あらかじめ割り当てない / |
|||
* 仮想ディスクを単一ファイル) |
|||
== Installing Squeeze == |
|||
== Squeeze インストール == |
|||
=== |
=== Running Installer === |
||
インストーラで以下を指定 |
|||
* |
* Select '''Install''' (Not ''Graphical Install') |
||
* |
* Select '''English''' at Choose language |
||
* |
* Select '''Japan''' at Choose country |
||
* |
* Select '''United States''' at Default locale |
||
* Select '''American English''' at Keymap to use |
|||
* 「Keymap to use」で「American English」を選択 |
|||
* |
* Select as below at Configure network |
||
** |
** Hostname is '''sambapdc''' |
||
** |
** Domain Name is '''sambadom.local''' |
||
* |
* Set as below at Set up users and passwords |
||
** |
** Set '''samba''' at Root password |
||
** Push ''<Go Back>'' several times until '''Debian installer main menu''' is shown at Full name for new user in Set up users and passwords |
|||
** ''「Set up users and passwords」の「Full name for new user」で |
|||
: Remember that lots of unused packages are installed if you continue to install as usual |
|||
* 「Debian installer main menu」になるまで、何度か「<Go back>」を選択'' |
|||
* Select as below at Partition disks |
|||
: これを行わずに普通にインストールを続行すると、無用なパッケージがイン |
|||
** Select '''Guided - use entire disk''' (defalt) |
|||
* ストールされるので注意。 |
|||
** Select '''All files in one partition''' (default) |
|||
* 「Partition disks」で以下を指定 |
|||
** Push '''Finish partitioning and write changes to disk''' |
|||
** 「Guided - use entire disk(デフォルト)」を選択 |
|||
** Select '''<Yes>''' at Write changes to disks? |
|||
** パーティション構成で「All files in one partition(デフォルト)」を |
|||
* Basic packages are installed during Installing the base system Window. |
|||
* 選択 |
|||
* Select '''Install the GRUB boot loader on a hard disk''' |
|||
** 「Finish partitioning and write changes to disk」を押す |
|||
** Select '''<Yes>''' at Install the GRUB boot loader to the master boot record? |
|||
** 「Write changes to disks?」に <Yes>を選択 |
|||
* Select '''<Continue>''' at Installation complete |
|||
* ここで「Installing the base system」画面になり、基本的なパッケージが |
|||
* インストールされる |
|||
* 「Install the GRUB boot loader on a hard disk」を選択 |
|||
** Install the GRUB boot loader to the master boot record? に <yes> を |
|||
* 選択 |
|||
* Installation complete で <Continue> |
|||
: ここで再起動が行われる |
|||
=== Basic settings === |
|||
このほか聞かれた場合は、以下のように選択 |
|||
* Added settings for eth1 if needed |
|||
* Install the base system を選択 |
|||
* Kernel to install で「linux-image-2.6-686」を選択 |
|||
* Use a network mirror で <No> |
|||
: Added these settings in /etc/network/interfaces |
|||
=== 基本的な設定 === |
|||
* eth1 用の設定を追加(オプション) |
|||
: 仮想マシンのイメージを他で転用すると、仮想マシン起動時に「Create new identity」といったメッセージが表示される。ここで Yes を選択した場合は MAC アドレスが変更されるため、 OS から認識されるインタフェース名も eth0 ではなく eth1 や eth2 などになる。そのための設定 |
|||
: /etc/network/interfaces に以下を追加(eth1の場合) |
|||
allow-hotplug eth1 |
allow-hotplug eth1 |
||
iface eth1 inet dhcp |
iface eth1 inet dhcp |
||
* Configure APT |
|||
* APT コマンドの設定とパッケージの更新 |
|||
: /etc/apt/sources.list |
: Modify /etc/apt/sources.list |
||
<pre> |
<pre> |
||
deb http://ftp.jp.debian.org/debian etch main |
deb http://ftp.jp.debian.org/debian etch main |
||
85行目: | 65行目: | ||
</pre> |
</pre> |
||
: Note that only '''main''' is set because of reducing disk space. |
|||
: ディスク容量節約のため、'''main''' しか設定していないので注意。必要に応じて '''contrib''' や '''non-free''' も設定すること。 |
|||
* Specify tmpfs for filesystem of /tmp |
|||
* /tmp を tmpfs にする(オプション→設定済) |
|||
: /etc/fstab |
: add /etc/fstab as below: |
||
/dev/shm /tmp tmpfs defaults 0 0 |
/dev/shm /tmp tmpfs defaults 0 0 |
||
: This is not necessary but reduces disk space for install |
|||
: これは、今後のインストール作業に際して、可能な限りディスク領域を消費しないためのもので、必須ではない。 |
|||
* Specify tmpfs for /var/cache/apt |
|||
* /var/cache/apt を tmpfs にする(オプション→設定済) |
|||
: /etc/fstab |
: add /etc/fstab as below: |
||
/dev/shm /var/cache/apt tmpfs defaults 0 0 |
/dev/shm /var/cache/apt tmpfs defaults 0 0 |
||
: This is not necessary but reduces disk space for install |
|||
: これは、今後のインストール作業に際して、可能な限りディスク領域を消費しないためのもので、必須ではない。 |
|||
: Enable these changes |
|||
: 設定を行った場合は、一度再起動するか、以下のように mount コマンドで上記設定を有効にする |
|||
# mount /tmp |
# mount /tmp |
||
# mount /var/cache/apt |
# mount /var/cache/apt |
||
* Installing ftp |
|||
* ftp のインストール(オプション→設定済) |
|||
: Uses only to receive files |
|||
: ファイルの受渡し用であり、動作上は不要 |
|||
# apt-get install ftp |
# apt-get install ftp |
||
# apt-get clean |
# apt-get clean |
||
* Installing packages for ACL and extended attributes |
|||
* ssh のインストール(オプション) |
|||
# apt-get install ssh |
|||
# apt-get clean |
|||
: SSH クライアントも併せてインストールされる。 |
|||
* lv(ページャ)のインストール(オプション) |
|||
# apt-get install lv |
|||
* ACLおよび拡張属性関連のパッケージインストール |
|||
# apt-get install attr acl |
# apt-get install attr acl |
||
* |
* Add acl,user_xattr as mount option in /etc/fstab |
||
: ''errors=remount-ro'' |
: change '''errors=remount-ro''' to '''defaults,acl,user_xattr,errors=remount-ro''' |
||
に変更する。 |
|||
: change mount options with remount option |
|||
: 変更後再起動するか、例えば以下のように remount オプションにより動的にマウントオプションを変更する。 |
|||
mount -o remount,rw,acl,user_xattr,errors=remoun-ro /dev/sda1 / |
mount -o remount,rw,acl,user_xattr,errors=remoun-ro /dev/sda1 / |
||
206行目: | 176行目: | ||
: Add mkhomedir option in pam_winbind.so line. |
: Add mkhomedir option in pam_winbind.so line. |
||
=== crackcheck |
=== Installing crackcheck command === |
||
* Installing cracklib package |
|||
* cracklib パッケージのインストール |
|||
# apt-get install libcrack2 |
# apt-get install libcrack2 |
||
: crackcheck |
: used by crackcheck command |
||
Run on the box where development packages are installed. |
|||
開発環境のあるマシン上で以下を実施 |
|||
# apt-get install cracklib2-dev |
# apt-get install cracklib2-dev |
||
223行目: | 193行目: | ||
# strip crackcheck |
# strip crackcheck |
||
Copy '''crackcheck''' binary to /usr/local/sbin/crackcheck on sambapdc |
|||
生成された crackcheck バイナリを、今回構築するマシンの |
|||
/usr/local/sbin/crackcheck にインストール。 |
|||
=== mgrshare |
=== Installing mgrshare script === |
||
Extract mgrshare script (included in |
|||
mgrshare スクリプトを作成の上、以下を実施( mgrshare は [http://wiki.samba.gr.jp/mediawiki/images/1/10/Sambapdc4.tar.gz sambapdc4.tar.gz] 内にあります) |
|||
[http://wiki.samba.gr.jp/mediawiki/images/1/10/Sambapdc4.tar.gz |
|||
sambapdc4.tar.gz] ) and install: |
|||
# mv mgrshare /usr/local/sbin/mgrshare |
# mv mgrshare /usr/local/sbin/mgrshare |
||
# chmod +x /usr/local/sbin/mgrshare |
# chmod +x /usr/local/sbin/mgrshare |
||
=== |
=== Installing smbchsh === |
||
Extract smbchsh script (included in |
|||
一般ユーザがシェルを変更できるように以下のスクリプトを |
|||
[http://wiki.samba.gr.jp/mediawiki/images/1/10/Sambapdc4.tar.gz |
|||
/usr/local/bin/smbchsh としてインストール |
|||
sambapdc4.tar.gz] ) and install to /usr/local/bin/smbchsh. |
|||
Here is the content of smbchsh: |
|||
#!/bin/sh |
#!/bin/sh |
||
248行目: | 222行目: | ||
" | ldapmodify -x -D "uid=${USER},ou=users,dc=samba,dc=local" -W |
" | ldapmodify -x -D "uid=${USER},ou=users,dc=samba,dc=local" -W |
||
=== remove-old-files-in-recycle-bin |
=== Installing remove-old-files-in-recycle-bin === |
||
Extract remove-old-files-in-recycle-bin script (included in |
|||
ごみ箱内の古いファイルを削除するスクリプト例 |
|||
[http://wiki.samba.gr.jp/mediawiki/images/1/10/Sambapdc4.tar.gz |
|||
/usr/local/sbin/remove-old-files-in-recycle-bin としてインストール |
|||
sambapdc4.tar.gz] ) and install as /usr/local/sbin/remove-old-files-in-recycle-bin: |
|||
#!/bin/sh |
#!/bin/sh |
||
268行目: | 243行目: | ||
done |
done |
||
=== Creating home directory === |
|||
=== ホームディレクトリの作成 === |
|||
# mkdir /home/SAMBADOM |
# mkdir /home/SAMBADOM |
||
=== smbusers |
=== Creating smbusers file === |
||
# touch /etc/samba/smbusers |
|||
Extract smbusers file (included in |
|||
=== リモートログイン用アカウントの作成(オプション) === |
|||
[http://wiki.samba.gr.jp/mediawiki/images/1/10/Sambapdc4.tar.gz |
|||
# groupadd -g 999 local |
|||
Sambapdc4.tar.gz] ) and install as /etc/samba/smbusers |
|||
# useradd -u 999 -g 999 -m local |
|||
# passwd local |
|||
:パスワードは「local」に設定。 |
|||
== Setting Samba + LDAP environment == |
== Setting Samba + LDAP environment == |
||
630行目: | 602行目: | ||
* Removing VMware log files |
* Removing VMware log files |
||
== 動作確認 == |
|||
=== Windows XP Professional SP3 から Samba ドメインに参加 === |
|||
* ドメインに参加 |
|||
* Administrator としてログオン |
|||
=== 動作確認 === |
|||
* 初期状態で |
|||
** ssh をインストールした上で、ldap01 として ssh でリモートマシンからログインが成功する。その際、ホームディレクトリが自動で作成される |
|||
** smbchsh コマンドによりシェルを変更できる |
|||
ldap01@sambapdc:~$ /usr/local/bin/smbchsh /bin/sh |
|||
Enter LDAP Password: |
|||
modifying entry "uid=ldap01,ou=users,dc=samba,dc=local" |
|||
ldap01@sambapdc:~$ getent passwd ldap01 |
|||
ldap01:*:10002:10000:ldap01:/home/SAMBADOM/ldap01:/bin/sh |
|||
** ldap01 として Windows XP Professional にログオンできる (パスワード ldap01) |
|||
* smbpasswd コマンドによりパスワードを変更できる |
|||
: その際、crackcheck コマンドにより、簡単なパスワードは設定できない |
|||
** ldap01 として NTWS40 にログオンできる (パスワードは変更後) |
|||
** ldap01 として ログインが成功する(パスワードは変更後) |
|||
* passwd コマンドによりパスワードを変更できる |
|||
: 変更後のパスワードでコンソールログインと smbclient によるアクセスが成功する |
|||
** ldap01 として Windows XP Professinal にログオンできる (パスワードは変更後) |
|||
** ldap01 として変更後のログインが成功する(パスワードは変更後) |
|||
* Windows XP Professional 以降で Ctrl+Alt+Del した画面のパスワードの変更、からパスワードが変更できる |
|||
: その際、crackcheck コマンドにより、簡単なパスワードは設定できない |
|||
** ldap01 として NTWS40 にログオンできる (パスワードは変更後) |
|||
** ldap01 として ssh でリモートマシンからログインが成功する(パスワードは変更後) |
|||
* Windows 2000 に Administrator としてログオンして、「コンピュータ管理」ツールから |
|||
** ファイル共有が作成できる |
|||
** 作成したファイル共有にアクセスできる |
|||
** ファイル共有が削除できる |
2011年8月15日 (月) 16:40時点における最新版
Get release image for Debian GNU/Linux
Download small CD
- Actually use debian-6.0.0-i386-netinst.iso
Build VMware Virtual Machine
How to create VM
Run the Virtual Machine Wizard
- Select Custom
- Select Workstation 5 as Hardware compatibility
- Do not check ESX Server
- Select Linux as guest OS
- Select Debian 5 as version
- Set sambapdc as VM's name
- Set 1 as number of CPU
- Set 256MB as available memory
- Leave NAT at Network Connection
- Leave LSI Logic at I/O controller type
- Select Create new virtual disk
- Select SCSI as type of virtual disk and leave other settings
Installing Squeeze
Running Installer
- Select Install (Not Graphical Install')
- Select English at Choose language
- Select Japan at Choose country
- Select United States at Default locale
- Select American English at Keymap to use
- Select as below at Configure network
- Hostname is sambapdc
- Domain Name is sambadom.local
- Set as below at Set up users and passwords
- Set samba at Root password
- Push <Go Back> several times until Debian installer main menu is shown at Full name for new user in Set up users and passwords
- Remember that lots of unused packages are installed if you continue to install as usual
- Select as below at Partition disks
- Select Guided - use entire disk (defalt)
- Select All files in one partition (default)
- Push Finish partitioning and write changes to disk
- Select <Yes> at Write changes to disks?
- Basic packages are installed during Installing the base system Window.
- Select Install the GRUB boot loader on a hard disk
- Select <Yes> at Install the GRUB boot loader to the master boot record?
- Select <Continue> at Installation complete
Basic settings
- Added settings for eth1 if needed
- Added these settings in /etc/network/interfaces
allow-hotplug eth1 iface eth1 inet dhcp
- Configure APT
- Modify /etc/apt/sources.list
deb http://ftp.jp.debian.org/debian etch main deb http://security.debian.org/ etch/updates main
- Note that only main is set because of reducing disk space.
- Specify tmpfs for filesystem of /tmp
- add /etc/fstab as below:
/dev/shm /tmp tmpfs defaults 0 0
- This is not necessary but reduces disk space for install
- Specify tmpfs for /var/cache/apt
- add /etc/fstab as below:
/dev/shm /var/cache/apt tmpfs defaults 0 0
- This is not necessary but reduces disk space for install
- Enable these changes
# mount /tmp # mount /var/cache/apt
- Installing ftp
- Uses only to receive files
# apt-get install ftp # apt-get clean
- Installing packages for ACL and extended attributes
# apt-get install attr acl
- Add acl,user_xattr as mount option in /etc/fstab
- change errors=remount-ro to defaults,acl,user_xattr,errors=remount-ro
- change mount options with remount option
mount -o remount,rw,acl,user_xattr,errors=remoun-ro /dev/sda1 /
Build Samba + LDAP environment
Installing and setting packages
Install and Configuring libnss-ldap and libpam-ldap
apt-get install libnss-ldap libpam-ldap
- Setting of libnss-ldap
- URL is ldapi:///
- DN is dc=sambadom,dc=local
- LDAP version is 3
- LDAP account for root is cn=admin,dc=sambadom,dc=local
- Password is ldap
- Settings of libpam-ldap
- Allow LDAP admin account ... is <Yes>
- Does the LDAP database require login? is <No>
- LDAP account for root is cn=admin,dc=sambadom,dc=local
- Password is ldap
- Adding LDAP into /etc/nsswitch.conf file
--- nsswitch.conf.org 2009-09-10 03:02:29.000000000 +0900 +++ nsswitch.conf 2009-09-07 22:10:09.000000000 +0900 @@ -4,9 +4,9 @@ # If you have the `glibc-doc-reference' and `info' packages installed, try: # `info libc "Name Service Switch"' for information about this file. -passwd: compat -group: compat +passwd: compat ldap +group: compat ldap shadow: compat hosts: files dns networks: files
Installing Samba and OpenLDAP
- installing slapd package
# apt-get install slapd ldap-utils
- Set ldap as Admin password
ldap-utils package is for management purpose, so it is not required for running, although the description is assumed it is installed.
- Installing Samba packages
# apt-get install samba winbind smbclient
- Set SAMBADOM as workgroup/domain name
smbclient package is for management and test purpose, so it is not required for running.
- Installing pam_smbpass package
# apt-get install libpam-smbpass
- Removing nscd
- Running nscd sometime makes a trouble that adding or removing an user or a group is not affected immediately.
# apt-get remove nscd
PAM configuration
Because pam-auth-update command automatically sets PAM related-files, basically we do not need to edit them manually.
But we have to set these settings manually:
- /etc/pam.d/common-password
- Comment out pam_winbind.so line.
- /etc/pam.d/common-session
- Add mkhomedir option in pam_winbind.so line.
Installing crackcheck command
- Installing cracklib package
- apt-get install libcrack2
- used by crackcheck command
Run on the box where development packages are installed.
# apt-get install cracklib2-dev
# apt-get install samba-doc # cd /usr/share/doc/samba-doc/examples/auth/crackcheck # make # strip crackcheck
Copy crackcheck binary to /usr/local/sbin/crackcheck on sambapdc
Extract mgrshare script (included in [http://wiki.samba.gr.jp/mediawiki/images/1/10/Sambapdc4.tar.gz sambapdc4.tar.gz] ) and install:
# mv mgrshare /usr/local/sbin/mgrshare # chmod +x /usr/local/sbin/mgrshare
Installing smbchsh
Extract smbchsh script (included in [http://wiki.samba.gr.jp/mediawiki/images/1/10/Sambapdc4.tar.gz sambapdc4.tar.gz] ) and install to /usr/local/bin/smbchsh.
Here is the content of smbchsh:
#!/bin/sh SHELL=$1 echo "dn: uid=${USER},ou=users,dc=samba,dc=local changetype: modify replace: loginShell loginShell: $1 " | ldapmodify -x -D "uid=${USER},ou=users,dc=samba,dc=local" -W
Installing remove-old-files-in-recycle-bin
Extract remove-old-files-in-recycle-bin script (included in [http://wiki.samba.gr.jp/mediawiki/images/1/10/Sambapdc4.tar.gz sambapdc4.tar.gz] ) and install as /usr/local/sbin/remove-old-files-in-recycle-bin:
#!/bin/sh trashdir=.recycle rootdir=/var/lib/samba/shares olddays=14 cd ${rootdir} for targetdir in *; do if [ -d ${targetdir}/${trashdir} ]; then cd ${targetdir}/${trashdir} find . -atime +${olddays} -exec rm {} \; fi done
Creating home directory
# mkdir /home/SAMBADOM
Creating smbusers file
Extract smbusers file (included in [http://wiki.samba.gr.jp/mediawiki/images/1/10/Sambapdc4.tar.gz Sambapdc4.tar.gz] ) and install as /etc/samba/smbusers
Setting Samba + LDAP environment
Setting LDAP
Remember that LDAP settings are stored in LDAP after Squeeze
- Installing schema file for Samba
# apt-get install samba-doc # apt-get clean
# zcat /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz > /etc/ldap/schema/samba.schema
# apt-get remove samba-doc # apt-get clean
- samba-doc package is removed after extracting schema file
- Generating LDIF file for Samba schema
# cd /tmp # ln -s /etc/ldap/schema . # mkdir dummy_slapd.d
- Creating /tmp/dummy_slapd.conf file as below:
include schema/core.schema include schema/cosine.schema include schema/inetorgperson.schema include schema/nis.schema include schema/samba.schema
# slaptest -f dummy_slapd.conf -F dummy_slapd.d config file testing succeeded
- Modifying LDIF file
Rename cn={4}samba.ldif under dummy_slapd.d/cn=config/cn=schema to samba.ldif
and modify as below:
- The top 3 lines before:
dn: cn={4}samba objectClass: olcSchemaConfig cn: {4}samba
- The top 3 lines after:
dn: cn=samba,cn=schema,cn=config objectClass: olcSchemaConfig cn: samba
- The last 7 lines before:
structuralObjectClass: olcSchemaConfig entryUUID: a671adca-3aa0-1030-8ae6-516ef773ec5f creatorsName: cn=config createTimestamp: 20110704154721Z entryCSN: 20110704154721.872107Z#000000#000#000000 modifiersName: cn=config modifyTimestamp: 20110704154721Z
- The last 7 line after:
(Removed)
- Register samba.ldif
# ldapadd -Y EXTERNAL -H ldapi:/// -f samba.ldif adding new entry "cn=samba,cn=schema,cn=config"
- Initial settings
- Create sambadom.ldif as below:
dn: olcDatabase={1}hdb,cn=config changetype:modify add: olcDbIndex olcDbIndex: uidNumber,gidNumber,uid,sambaSID,cn,memberuid eq - add: olcAccess olcAccess: to attrs=loginShell by dn="cn=admin,dc=samba,dc=local" write by self write by * read olcAccess: to attrs=sambaNTPassword,sambaLMPassword,sambaPwdLastSet,sambaPwdMustChange by dn="cn=admin,dc=samba,dc=local" write by self write by * none
# ldapadd -Y EXTERNAL -H ldapi:/// -f sambadom.ldif adding new entry "olcDatabase={1}hdb,cn=config"
Create initial schema
- Create sambadom.local.ldif file as below:
dn: ou=users,dc=sambadom,dc=local objectClass: top objectClass: organizationalUnit ou: users dn: ou=groups,dc=sambadom,dc=local objectClass: top objectClass: organizationalUnit ou: groups dn: ou=idmap,dc=sambadom,dc=local objectClass: top objectClass: organizationalUnit ou: idmap dn: ou=computers,dc=sambadom,dc=local objectClass: top objectClass: organizationalUnit ou: computers
- Register sambadom.local.ldif with ldapadd :
# cat sambadom.local.ldif | ldapadd -D cn=admin,dc=sambadom,dc=local -W -x -H ldapi:/// Enter LDAP Password: adding new entry "ou=users,dc=samba,dc=local" adding new entry "ou=groups,dc=samba,dc=local" ...
Setting Samba
- Stopping Samba
# /etc/init.d/samba stop # /etc/init.d/winbind stop
- Installing smb.conf
Create smb.conf as /etc/samba/smb.conf (included in sambapdc4.tar.gz)
# mv /etc/samba/smb.conf /etc/samba/smb.conf.org # mv smb.conf /etc/samba/smb.conf
- Installing smbusers file
Create smbusers as /etc/samba/smbusers
- Store LDAP password
# smbpasswd -w ldap Setting stored password for "cn=admin,dc=sambadom,dc=local" in secrets.tdb
- Store initial settings into LDAP
Start winbindd (only) before running 'net sam provision'
# /etc/init.d/winbind start Starting the Winbind daemon: winbind. # net sam provision Checking for Domain Users group. Adding the Domain Users group. Checking for Domain Admins group. Adding the Domain Admins group. Check for Administrator account. Adding the Administrator user. Checking for Guest user. Adding the Guest user. Checking Guest's group. Adding the Domain Guests group.
- Initial settings for Administrator user
- Setting his password 'samba'
# smbpasswd Administrator New SMB password: <== samba Retype new SMB password: <== samba
- Starting Samba
Setting automated home directory creation
- Create a file as /usr/local/sbin/createhomedir and chmod +rx :
- This setting is needed because automated home directory creation via PAM cannot work with Samba.
#!/bin/bash homedir=/home/$1/$2 if [ ! -d $homedir ]; then mkdir $homedir chmod 700 $homedir chown $2:domusers $homedir fi exit 0
Setting syslog
- Creating a file as /etc/rsyslog.d/samba.conf :
local1.* -/var/log/samba/log.audit
- And
# touch /var/log/samba/log.audit # /etc/init.d/rsyslog restart
- Creating a file as /etc/logrotate.d/samba-syslog :
/var/log/samba/log.audit { rotate 4 weekly missingok notifempty compress delaycompress sharedscripts postrotate invoke-rc.d rsyslog reload > /dev/null endscript }
# mkdir /var/lib/samba/shares # cd /var/lib/samba/shares
- 'NETLOGON' share
# mkdir /var/lib/samba/shares/netlogon
# mkdir /var/lib/samba/shares/printers # chmod 775 domadmins # chgrp domadmins printers
- 'profiles' share
# mkdir /var/lib/samba/shares/profiles # chmod 1777 /var/lib/samba/shares/profiles
- 'shared' share
- shares where users who belong to Domain Users group can read and write
# mkdir /var/lib/samba/shares/shared # chgrp domusers shared # chmod g+ws shared
- 'aclshare1' share
- Create aclshare1ro and aclshare1rw group and confirm their GID before creating 'aclshare1'
# net sam createlocalgroup aclshare1ro Created local group aclshare1ro with RID 1001 # net sam createlocalgroup aclshare1rw Created local group aclshare1rw with RID 1002
# net groupmap list ntgroup=aclshare1ro aclshare1ro (S-1-5-21-3643489711-3443204727-2039806625-1001) -> 10011 # net groupmap list ntgroup=aclshare1rw aclshare1rw (S-1-5-21-3643489711-3443204727-2039806625-1002) -> 10012
# mkdir /var/lib/samba/shared/aclshare1 # chown root:root aclshare1 # chmod 770 aclshare1 # setfacl -m group:10011:r-x aclshare1 # setfacl -m group:10012:rwx aclshare1 # setfacl -d -m group:10011:r-x aclshare1 # setfacl -d -m group:10012:rwx aclshare1
- 'aclshare2' share
- Create aclshare2ro and aclshare2rw group and confirm their GID before creating 'aclshare2'
# net sam createlocalgroup aclshare2ro Created local group aclshare1ro with RID 1003 # net sam createlocalgroup aclshare2rw Created local group aclshare1rw with RID 1004
# net groupmap list ntgroup=aclshare1ro aclshare1ro (S-1-5-21-3643489711-3443204727-2039806625-1003) -> 10013 # net groupmap list ntgroup=aclshare1rw aclshare1rw (S-1-5-21-3643489711-3443204727-2039806625-1004) -> 10014
# mkdir /var/lib/samba/shared/aclshare1 # chown root:root aclshare1 # chmod 770 aclshare1 # setfacl -m group:10014:rwx aclshare2 # setfacl -m group:10013:r-x aclshare2 # setfacl -d -m group:10014:rwx aclshare2 # setfacl -d -m group:10013:r-x aclshare2
- 'share_test' share
# mkdir /var/lib/samba/shares/share_test # chmod 1777 share_test
# mkdir share_test/hide_unreadable # cd share_test/hide_unreadable # touch normal.txt # touch secure.txt # chmod 600 secure.txt
# mkdir share_test/veto_files # cd share_test/veto_files # touch dummy.exe # mkdir GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}
- Installing var-check script
- works with "root preexec" line on share_test share and shows all value of Samba variables. Installing as /usr/local/sbin/var-check:
#!/bin/sh VARLIST='%U %G %h %L %m %M %R %d %a %I %i %T %D %w %v %V %S %P %u %g %H %N %p e1 e2' rm /tmp/var.txt for var in $VARLIST; do echo "$var : $1" >> /tmp/var.txt shift done
Creating users
- Creating ldap01, ldap02 and ldap03 user
- ldap01 and ldap02 user belong to aclshare1rw and aclshare2rw group
- ldap03 user belongs to aclshare1ro and aclshare2ro group
- Their home directory is set as \\sambapdc\username, mounted to H:
- Their username is set as "LDAP User nn"
- Their password is set not to expired.
- For ldap01 user
# smbpasswd -a ldap01 # pdbedit -c "[X]" -f "LDAP01 user" -h '\\sambapdc\ldap01' -D h: ldap01
# net sam addmem aclshare1rw ldap01 Added SAMBADOM\ldap01 to SAMBADOM\aclshare1rw # net sam addmem aclshare2rw ldap01 Added SAMBADOM\ldap01 to SAMBADOM\aclshare2rw
Installing SWAT (Option)
- Installing SWAT
# apt-get install swat
- Setting below to /etc/hosts.allow file
- Resticted access into local subnet.
ALL: LOCAL
Last of all
- Initialization WINS database
Remove wins.dat and wins.tdb under /var/lib/samba
- Removing VMware log files