- PR -

OpenLDAPの認証でauthentication failure

1
投稿者投稿内容
kent
会議室デビュー日: 2004/05/10
投稿数: 4
投稿日時: 2004-05-10 04:09
はじめまして。石戸谷と申します。
三日ほど前に手持ちのRedhat9にSubVersionを導入しようといじり始めて、どうせならLDAPで認証をして見ようと思いいろいろとやってみているのですが、どうしてもわからないので質問させていただきます。

OpenLDAPをインストールして、各種設定を行った後sshを利用してログインすると
コード:

May 10 02:58:29 hoge sshd(pam_unix)[3390]: check pass; user unknown
May 10 02:58:29 hoge sshd(pam_unix)[3390]: authentication failure; logname= uid=
0 euid=0 tty=NODEVssh ruser= rhost=192.168.1.12
May 10 02:58:31 hoge sshd(pam_unix)[3392]: session opened for user test by (uid=
503)


というエラーが出てしまいます。ただしログイン自体は出来ています。このエラーはなぜ起こるのかご教示ください。
ちなみに、sshを/usr/sbin/ssh -d -dとして立ち上げてログを見るとputtyを立ち上げてプロンプトが表示され、ユーザー名を入れてリターンを押したタイミングで
コード:

debug2: input_userauth_request: setting up authctxt for test
debug1: Starting up PAM with username "test"
debug1: PAM setting rhost to "192.168.1.12"
debug2: monitor_read: 41 used once, disabling now
debug2: monitor_read: 3 used once, disabling now
debug2: input_userauth_request: try method none
debug1: PAM Password authentication for "test" failed[7]: Authentication failure
Failed none for test from 192.168.1.12 port 3561 ssh2
Failed none for test from 192.168.1.12 port 3561 ssh2
debug1: userauth-request for user test service ssh-connection method keyboard-in
teractive
debug1: attempt 1 failures 1


というログが出ていました。よろしくお願いいたします。

やったことは下記です。長文になります申し訳ありません。
コード:

useradd test
passwd test
データを控えてldifファイル作成
userdel test



作成したldifファイルは下記です。
コード:

dn: dc=hoge,dc=ath,dc=cx
objectclass: dcObject
dc: hoge

dn: ou=People,dc=hoge,dc=ath,dc=cx
ou: people
objectclass: organizationalUnit

dn: ou=Group,dc=hoge,dc=ath,dc=cx
ou: group
objectclass: organizationalUnit

dn: uid=test,ou=People,dc=hoge,dc=ath,dc=cx
uid: test
cn: test
objectclass: posixAccount
objectclass: shadowAccount
userPassword: {MD5}**********************
uidNumber: 503
gidNumber: 503
shadowLastChange: 12546
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
homeDirectory: /home/test


上記のldifをuser.ldifとして保存し
コード:
ldapadd -h localhost -x -D "cn=admin,dc=hoge,dc=ath,dc=cx" -x -


W -f test.ldif
として追加し、
コード:
ldapsearch -x -D "cn=admin,dc=hoge,dc=ath,dc=cx" -W


とすると
コード:

# hoge, ath, cx
dn: dc=hoge,dc=ath,dc=cx
objectClass: dcObject
dc: hoge

# People, hoge, ath, cx
dn: ou=People,dc=hoge,dc=ath,dc=cx
ou: people
objectClass: organizationalUnit

# Group, hoge, ath, cx
dn: ou=Group,dc=hoge,dc=ath,dc=cx
ou: group
objectClass: organizationalUnit

# test, People, hoge, ath, cx
dn: uid=test,ou=People,dc=hoge,dc=ath,dc=cx
uid: test
cn: test
objectClass: posixAccount
objectClass: shadowAccount
userPassword:: *********************************
uidNumber: 503
gidNumber: 503
shadowLastChange: 12546
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
homeDirectory: /home/test


と追加されました。

---------------
以下設定ファイルです。

/etc/ldap.conf
コード:

host hoge.ath.cx
base dc=hoge,dc=ath,dc=cx
binddn cn=admin,dc=hoge,dc=ath,dc=cx
bindpw **************
pam_filter objectclass=posixAccount
pam_login_attribute uid
pam_password md5
ssl start_tls


/etc/openldap/slapd.conf
コード:
include         /etc/openldap/schema/core.schema

include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema
include /etc/openldap/schema/redhat/rfc822-MailMember.schema
include /etc/openldap/schema/redhat/autofs.schema
include /etc/openldap/schema/redhat/kerberosobject.schema
pidfile /var/run/slapd.pid
argsfile /var/run/slapd.args
TLSCertificateFile /usr/local/apache2/conf/certs/server.crt
TLSCertificateKeyFile /usr/local/apache2/conf/certs/server.key
TLSCACertificateFile /usr/share/ssl/certs/slapd.pem
access to attribute=userPassword
by dn="cn=admin,dc=hoge,dc=ath,dc=cx" write
by self write
by anonymous auth
by * none
access to *
by dn="cn=admin,dc=hoge,dc=ath,dc=cx" write
by self write
by * read
database ldbm
suffix "dc=hoge,dc=ath,dc=cx"
rootdn "cn=admin,dc=hoge,dc=ath,dc=cx"
rootpw **********************************
directory /usr/local/ldap/ldbm
index objectClass,uid,uidNumber,gidNumber,memberUid eq
index cn,mail,surname,givenname eq,subinitial


/etc/pam.d/system-auth
コード:
#%PAM-1.0

# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth sufficient /lib/security/$ISA/pam_ldap.so
auth required /lib/security/$ISA/pam_env.so
auth sufficient /lib/security/$ISA/pam_unix.so likeauth nullok use_fir
st_pass
auth required /lib/security/$ISA/pam_deny.so

account [default=bad success=ok user_unknown=ignore service_err=ignore syste
m_err=ignore] /lib/security/$ISA/pam_ldap.so
account required /lib/security/$ISA/pam_unix.so

password required /lib/security/$ISA/pam_cracklib.so retry=3 type=
password sufficient /lib/security/$ISA/pam_ldap.so use_authtok
password sufficient /lib/security/$ISA/pam_unix.so nullok use_authtok md5
shadow
password required /lib/security/$ISA/pam_deny.so

session required /lib/security/$ISA/pam_limits.so
session optional /lib/security/$ISA/pam_ldap.so
session required /lib/security/$ISA/pam_unix.so



起動と終了は
コード:
/etc/init.d/ldap start|stop


でやっています。

今現在インストールされているパッケージのバージョンはそれぞれ
openldap : 2.0.27-8 (apt-get)
openssl : 0.9.7a-20.2 (apt-get)
openssh : 3.5p1-11 (apt-get)

カーネルバージョン
Linux serv 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux

[ メッセージ編集済み 編集者: kent 編集日時 2004-05-10 04:11 ]

[ メッセージ編集済み 編集者: kent 編集日時 2004-05-10 11:44 ]
ぽんす
ぬし
会議室デビュー日: 2003/05/21
投稿数: 1023
投稿日時: 2004-05-10 08:28
引用:

kentさんの書き込み (2004-05-10 04:09) より:
コード:
May 10 02:58:29 hoge sshd(pam_unix)[3390]: check pass; user unknown
May 10 02:58:29 hoge sshd(pam_unix)[3390]: authentication failure; logname= uid=
0 euid=0 tty=NODEVssh ruser= rhost=192.168.1.12




これをみると、LDAP がひけていないのだと思います。
# 手元にそーゆー環境がないので、どういうログが出るのだか
# イマイチ自信がありませんが。

pam が利用する LDAP 検索の設定は /etc/openldap/ldap.conf かな?
/etc/ldap.conf かしら? まあそのあたりで、検索サーバ(127.0.0.1
でいいのかしら)と検索ベース(ou=People,dc=hoge,dc=ath,dc=cx)
の設定が正しくなされているかどうか、確認してみてください。
kent
会議室デビュー日: 2004/05/10
投稿数: 4
投稿日時: 2004-05-10 12:06
ぽんすさん
ありがとうございます。
/etc/ldap.confですが、最初の投稿に間違ってldif.confという名前で書いていました。
/etc/openldap/ldap.confは/etc/ldap.confと同じ設定です。
検索ホスト及び検索ベースは
コード:
host hoge.ath.cx

base dc=hoge,dc=ath,dc=cx


となっています。
また検索ホスト名はhostname -f と一致させてあります。

ユーザー名testをLDAPで問い合わせるときにエラーが出てるんですよね・・・
userdelしてるので、/etc/nsswhich.confからldapを消すとuser unknownでログインできないんです。
何かわかりましたらよろしくお願いいたします。

[ メッセージ編集済み 編集者: kent 編集日時 2004-05-10 12:08 ]
ぽんす
ぬし
会議室デビュー日: 2003/05/21
投稿数: 1023
投稿日時: 2004-05-10 13:04
引用:

kentさんの書き込み (2004-05-10 12:06) より:
/etc/ldap.confですが、最初の投稿に間違ってldif.confという名前で書いていました。


おっと、そこは見てませんでした。
base は先に書いたように、ou=People,dc=hoge,dc=ath,dc=cx です。
# すみません、訂正です。ou=People は、あってもなくても
# どちらでもいいようですね。たぶん。

あと、binddn が指定されているのがちょっと気になりますが...
slapd.conf では
anonymous auth
となってますよね。この場合、pam がどう動作するか、ちょっと自信が
ないです。(いや、もともと pam をほとんど知らないのですが
base を修正してもダメだったら、ldap.conf から binddn と bindpw
の記述を外してみてはいかがでしょうか。

[ メッセージ編集済み 編集者: ぽんす 編集日時 2004-05-10 13:58 ]
kent
会議室デビュー日: 2004/05/10
投稿数: 4
投稿日時: 2004-05-10 14:34
ぽんすさんお付き合いいただきありがとうございます。
とりあえず、以下の項目を試しました。
1、basednとbasepwをコメントアウト:同じ結果
2、baseにou:Peopleを追加     :同じ結果
3、anonymous authを消してby * readにしてみる:同じ結果
でいろいろ組み合わせてそのたびにslapdを立ち上げなおしましたが、同じでした。
ん〜LDAPからパスワードとユーザー名が引けてないなら、認証できなくていいはずなのに・・・

コード:
May 10 14:32:19 d8-0 sshd(pam_unix)[5031]: check pass; user unknown
May 10 14:32:19 d8-0 sshd(pam_unix)[5031]: authentication failure; logname= uid=
0 euid=0 tty=NODEVssh ruser= rhost=192.168.1.12
May 10 14:32:23 d8-0 sshd(pam_unix)[5035]: session opened for user test by (uid=
503)


これpam_unixのエラーですよね・・・LDAPを疑うんじゃなくて/etc/pam.d/system_authの記述を疑うべきなんでしょうか。
ぽんす
ぬし
会議室デビュー日: 2003/05/21
投稿数: 1023
投稿日時: 2004-05-10 15:18
全く申し訳ないんですが、私もおかしなことを書いてしまっています。

とりあえず、slapd.conf からアクセス制限の記述をコメントアウト
してから slapd を再起動して、試してみてはいかがでしょうか。
# base については下位のツリーも検査しますから ou=People が
# なくてもOK、anonymouth auth は... これはアクセス制限を
# かけるなら、そのままです。
もちろん、アクセス制限を外すということは誰でも読めるようになる
わけで、ブルート・フォース型のパスワード・クラックが可能に
なるので、ずっとそのままにしておくというのはやめたほうが
いいのですが。

> ん〜LDAPからパスワードとユーザー名が引けてないなら、認証できなくていいはずなのに・・・
nsswitch.conf に、ldap と files が記述してある、とか?

> これpam_unixのエラーですよね・・・
あら、そうですね。pam_ldap じゃないですねえ。sshd が ldap を
利用するようになっていない、とか?
ぽんす
ぬし
会議室デビュー日: 2003/05/21
投稿数: 1023
投稿日時: 2004-05-10 20:23
引用:

sshd が ldap を利用するようになっていない、とか?


これ、説明が足りませんでしたが /etc/pam.d/sshd が存在しなくて、
デフォルトの pam_unix を使う状態になっているんじゃあ
ないでしょうか、ということです。
kent
会議室デビュー日: 2004/05/10
投稿数: 4
投稿日時: 2004-05-11 13:28
ボンスさん返答遅れて申し訳ありませんでした。
サイトリニューアル中で、閲覧できなかったので。

上記問題ですが、/etc/pam.d/sshdは存在していましたが/etc/pam.d/system-authを参照するようになっていたので、pam_unixを利用しないように/etc/pam.d/sshdを書き換えたところ、エラーをはかなくなりました。

slapdの方のエラーだと思ってずっと考えていたので見落としていたようです。
お付き合いいただきありがとうございました。

#今度はWebdavでldapsが使えない・・・><
1

スキルアップ/キャリアアップ(JOB@IT)