2012年11月20日火曜日

Solaris10のldapclient設定時の認証失敗

OpenLDAPをLDAPサーバーとして、Solaris10をLDAPクライアントとした場合、sshログインなどを試した場合に、次のメッセージが出力されて認証に失敗する場合がある。

Nov 20 22:12:14 yasuma73 sshd[3958]: [ID 316739 auth.error] pam_ldap: no legal authentication method configured

これは、LDAPサーバーに平文パスワードを登録している場合に出力される警告で、CRYPT形式でパスワードを格納すれば問題なく認証可能となる。

2012年10月19日金曜日

Samba4 RC3をDCとしてセットアップ

環境

CentOS6.3環境にSamba4をAD DCとしてセットアップする手順をまとめる。

SNTP対応xntpdの設定


CentOS6のxntpdは、sntpに対応していないため、CentOS6のxntpdパッケージをもとに、xntpd-4.2.6をsntp対応のxntpdパッケージとして再ビルドする。

パッケージングの手順は省略...

作成したxntpのパッケージをインストールする。
# rpm -Uhv ntp*rpm

/etc/ntp.confに以下を追加

server 127.127.1.1
fudge 127.127.1.1  stratum 12
ntpsigndsocket /var/run/ntp_signd/
restrict default mssntp

ntpdを再起動
# /sbin/service ntpd restart

Bind9.8のインストール

DLZに対応したbind-9.8.3-P2パッケージをインストール
  • bind-9.8.3-P2.el6.x86_64.rpm
  • bind-libs-9.8.3-P2.el6.x86_64.rpm
  • bind-license-9.8.3-P2.el6.noarch.rpm
  • bind-utils-9.8.3-P2.el6.x86_64.rpm

Samba4のセットアップ

samba4パッケージに必要な次のパッケージをインストール

# yum install xinetd  

最初にsamba3パッケージ関連を削除

# rpm -e samba-client samba-common samba-winbind-clients libsmbclient --nodeps

samba4パッケージ一式をインストール。

Samba4のprovisioning


# /usr/bin/samba-tool domain provision
Realm [EXAMPLE.COM]: 
Domain [EXAMPLE]: 
Server Role (dc, member, standalone) [dc]: 
DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]: BIND9_DLZ
Administrator password: 
Retype password: 
Looking up IPv4 addresses
More than one IPv4 address found. Using 192.168.2.8
Looking up IPv6 addresses
No IPv6 address will be assigned
Setting up share.ldb
Setting up secrets.ldb
Setting up the registry
Setting up the privileges database
Setting up idmap db
Setting up SAM db
Setting up sam.ldb partitions and settings
Setting up sam.ldb rootDSE
Pre-loading the Samba 4 and AD schema
Adding DomainDN: DC=example,DC=com
Adding configuration container
Setting up sam.ldb schema
Setting up sam.ldb configuration data
Setting up display specifiers
Adding users container
Modifying users container
Adding computers container
Modifying computers container
Setting up sam.ldb data
Setting up well known security principals
Setting up sam.ldb users and groups
Setting up self join
Adding DNS accounts
Creating CN=MicrosoftDNS,CN=System,DC=example,DC=com
Creating DomainDnsZones and ForestDnsZones partitions
Populating DomainDnsZones and ForestDnsZones partitions
See /etc/samba/named.conf for an example configuration include file for BIND
and /etc/samba/named.txt for further documentation required for secure DNS updates
Setting up sam.ldb rootDSE marking as synchronized
Fixing provision GUIDs
A Kerberos configuration suitable for Samba 4 has been generated at /etc/samba/krb5.conf
Once the above files are installed, your Samba4 server will be ready to use
Server Role:           active directory domain controller
Hostname:              samba4
NetBIOS Domain:        EXAMPLE
DNS Domain:            example.com
DOMAIN SID:            S-1-5-21-858491299-1320590862-3958657269
A phpLDAPadmin configuration file suitable for administering the Samba 4 LDAP server has been created in /etc/samba/phpldapadmin-config.php.

Bindの設定

/etc/samba/named.txtに記載されている設定などをDNSに行う。

DLZ機能を利用可能とするための設定を /etc/named.confに追加する。
include "/etc/samba/named.conf";

Bind9.8.3を利用しているので、 /etc/named.confのoptionsセクションに、以下の設定を追加。

tkey-gssapi-keytab "/etc/samba/dns.keytab";

namedがファイルを読み込めるように、次のコマンドを実行

# chgrp named /etc/samba/dns.keytab
# chmod g+r /etc/samba/dns.keytab


namedが127.0.0.1以外のインターフェースもLISTENする用に、次の設定を /etc/named.confから削除
listen-on port 53 { 127.0.0.1; };
listen-on-v6 port 53 { ::1; };

namedを再起動
# /sbin/service named start

/var/log/messagesに次のように、DLZドライバの読み込みが行われている。

Oct 19 21:03:09 samba4 named[27126]: Loading 'AD DNS Zone' using driver dlopen
Oct 19 21:03:10 samba4 named[27126]: samba_dlz: started for DN DC=example,DC=com
Oct 19 21:03:10 samba4 named[27126]: samba_dlz: starting configure
Oct 19 21:03:10 samba4 named[27126]: samba_dlz: configured writeable zone 'example.com'
Oct 19 21:03:10 samba4 named[27126]: samba_dlz: configured writeable zone '_msdcs.example.com'

samba4を起動

sambaサービスを起動する。

# /sbin/service samba start

確認のため、別サーバーからアクセスしてみる。

$ smbclient -L samba4
Enter yasuma's password: 
Anonymous login successful
Domain=[EXAMPLE] OS=[Unix] Server=[Samba 4.0.0rc3]

Sharename       Type      Comment
---------       ----      -------
netlogon        Disk      
sysvol          Disk      
IPC$            IPC       IPC Service (Samba 4.0.0rc3)
Anonymous login successful
Domain=[EXAMPLE] OS=[Unix] Server=[Samba 4.0.0rc3]

Server               Comment
---------            -------

Workgroup            Master
---------            -------

DNSの確認のため、SRVレコードを確認してみる。

# dig @127.0.0.1 _ldap._tcp.example.com SRV

/etc/resolv.confを次の設定に変更する。

domain example.com
nameserver 192.168.2.8 (DCのIPアドレス)

Kerberosの設定

provisioning時に作成された/etc/samba/krb5.confをOSの/etc/krb5.confにコピーする。

# cp /etc/samba/krb5.conf /etc/krb5.conf

Kerberosの設定が正しいか次のコマンドで確認する。
  • レルム(EXAMPLE.COM)の部分は、大文字
  • パスワードはsamba4のprovisioning時に設定したものを入力する。

# kinit administrator@EXAMPLE.COM
Password for administrator@EXAMPLE.COM: 
Warning: Your password will expire in 41 days on Fri Nov 30 20:52:00 2012

正常にチケットが取得できていれば、次のklistコマンドでチケットが表示される。
# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: administrator@EXAMPLE.COM

Valid starting     Expires            Service principal
10/19/12 21:17:22  10/20/12 07:17:22  krbtgt/EXAMPLE.COM@EXAMPLE.COM
renew until 10/20/12 21:17:18

DNSの動的更新の確認

DNSのTSIG/GSSを利用した動的更新が動作することを確認するため、次のコマンドを実行して、正常にDNSの更新が行われることを確認する。

# /usr/sbin/samba_dnsupdate --verbose --all-names 
IPs: ['fe80::a00:27ff:fe8d:c1f0%eth1', 'fe80::a00:27ff:fea2:fee8%eth0', '192.168.2.8', '10.0.2.15']
Calling nsupdate for A example.com 192.168.2.8
Outgoing update query:

以上で、Samba4が正常にドメインコントローラーとしてセットアップ完了しているはず。

Samba4に必要なパッケージ

Bind 9.8以降(DLZ対応)

http://wiki.samba.org/index.php/Samba4/HOWTO#Step_7:_Configure_DNS

SNTP対応xntpd

MS-SNTP対応が必要とのこと。
http://www.whitemiceconsulting.com/2010/12/configuration-of-ntp-for-samba4.html

パッケージを用意する方法はこちら。
http://wiki.samba.org/index.php/Samba4/HOWTO#Step_10:_Configure_NTP_.28Optional.29


2012年5月11日金曜日

RHEL6のsudoのLDAP対応

RHEL6になって、LDAPクライアントの設定がnslcd.confなどに変更になった影響を受けて
sudoのLDAP連携が動作しなくなっていた。

この問題がRHEL6.3に含まれる sudo-1.7.4p5-8 で解決されていることを確認した。

RHEL6.3からのsudoでは、/etc/sudo-ldap.confにLDAP連携の設定を記載することで、
LDAPからsudo用エントリを参照することが可能になった。

/etc/sudo-ldap.conf
uri ldap://ldap1.example.com
sudoers_base ou=SUDOers,dc=example,dc=com

2012年3月14日水曜日

LightWorksインストール

オープンソースで公開される予定と噂の動画編集ソフトのLightWorksを使ってみたいと思って、
インストールなどの手順を調査中。

現在はベータ版ということで、ユーザー登録をすればこちらからダウンロード可能。
http://www.lightworksbeta.com/

ただし、標準ではコーデックがほとんど入っていないので、インストール前に次の2つをあらかじめインストールしておく必要あり。

-Matrox VFW codecs
- QuickTime
http://www.apple.com/quicktime/download/

オープンソース化されるにあたり、商用コーデックが含まれなくなるので、コンバーターツールもインストールしておくことがお勧めの様子。
http://lightworks.wikidot.com/formats

とりあえず、こちらのサイトで紹介されているMediaCoder2011をインストールしてみた。
インストール時にレジストリスキャンソフトのインストールも促されるが、不要なので、インストールしませんを選択しておいた。



2012年3月12日月曜日

python-ldapでmodifyTimeStampをsearch

通常のsearchでは取得できないmodifyTimeStampなどの属性を取得したいときは、attrslistに'+'を追加

rt = conn.search_s(base, ldap.SCOPE_SUBTREE, filter, ['*','+'])

2012年3月2日金曜日

OpenLDAPのschemaファイル

OpenLDAP用のschemaファイルを作成したところ、slaptestコマンドで確認すると次のエラーが表示された。
line 19: old format not supported

attributetype(1.3.6.1.4.1.xxx.xxx.xxx
              NAME 'example'

正解はこちら。 attributetypeの直後に空白が無いと上記のエラーになる。

attributetype (1.3.6.1.4.1.xxx.xxx.xxx
              NAME 'example'

2012年2月26日日曜日

winexeの返値

winexeを使って、Windows上のコマンドを実行する場合、CMD /Cを使うと、Windows上で実行したスクリプトの返値を受け取ることができる。

$ winexe -U DOMAIN\Administrator --system //192.168.0.1 CMD /C C:\script\test1

test1.batの内容が次のようなものであればexitに指定した返値をwinexeのコマンドの返値として受け取ることができる。
echo test1
exit 3
この場合、コマンドが正常終了するとwinexeの返値は3。




2012年2月23日木曜日

Google Appsの更新

1年に1回、Google Appsのライセンス料の支払いがやってきて、アカウント数に応じて料金が決まる。

しかし、アカウント数を減らしたいときは注意が必要。

デフォルトの設定だと、「すべてのライセンスを更新」になっていて、現在支払い済みのアカウント数で自動更新されてしまう。

ユーザーを削除して、減らしたアカウント数で更新したい場合は、
「ドメインの設定」の「支払い情報」で、「すべてのユーザーを自動更新する」に
切り替えておかないと、契約済みのアカウント数のまま自動更新されるので注意。

2012年2月22日水曜日

winexeで外部サーバーの共有にアクセス

Linuxなどでwinexeコマンドを使うと、Windowsサーバー上でコマンドを実行することができます。

$ winexe -U 'DOMAIN\Administrator%password' //servername

このとき、Windowsサーバー側で別サーバーのNASなどの共有をX:などにマッピングしていても、そのままではwinexe経由ではX:ドライブは見えません。

winexe経由で外部サーバーの共有を使いたい場合、winexeのコマンドの中でnet useを使って共有をドライブに割り当てる必要があります。

例えば、ファイルサーバー 192.168.0.100の共有 shareを利用したい場合、次のようなファイル(share.bat)を用意します。
net use X: \\192.168.0.100\share
X:
dir X:
exit
このコマンドをwinexe経由で実行したい場合、次のようにコマンドを実行します。

$ cat share.bat | winexe -U 'DOMAIN\Administrator%password' --runas='DOMAIN\Administrator%password' //servername cmd

このようにして、winexeを使って、Windows上で外部ファイルサーバーなどの共有にアクセスするコマンドを実行することが可能です。