mongokerberos 検証ツール
mongokerberosプログラムは、MongoDB で使用するためのプラットフォームの Kerberos 構成を確認し、MongoDB クライアントからの Kerberos 認証が期待どおりに機能することをテストするのに便利な方法を提供します。
mongokerberosツールは一般的な構成の問題の診断に役立ち、Kerberos 構成のトラブルシューティングを行う際に開始することをお勧めします。 詳しくは、 mongokerberosのドキュメントを参照してください。
mongokerberos は MongoDB Enterprise でのみ利用可能です。
Kerberos 構成デバッグ戦略
Kerberos mongodmongosを使用して または に対して開始または認証を開始するのが困難な場合は、次の点を考慮してください。
MongoDB Community Edition ではなく、MongoDB Enterprise を実行していることを確認します。 Kerberos 認証は MongoDB Enterprise の機能であり、MongoDB Community Edition バイナリでは機能しません。
MongoDB Enterprise を使用していることを確認するには、
--versionコマンドライン オプションをmongodまたはmongosに渡します。mongod --version このコマンドの出力で string
modules: subscriptionまたはmodules: enterpriseを探し、MongoDB Enterprise バイナリを使用していることを確認します。On Linux, ensure that the primary component of the service principal name (SPN) of the SPN is
mongodb. If the primary component of the SPN is notmongodb, you must specify the primary component using--setParameter saslServiceName.
On Linux, ensure that the instance component of the service principal name (SPN) in the keytab file matches the canonical system hostname of the
mongodormongosinstance. If themongodormongosinstance's system hostname is not in the keytab file, authentication will fail with aGSSAPI error acquiring credentials.error message.によって返される または
mongodmongosインスタンスのホスト名が完全修飾でない場合は、hostname -f--setParameter saslHostNameまたはmongodmongosを起動するときに、 を使用してインスタンスの完全修飾ドメイン名を設定します。MongoDB インスタンスと Kerberos インフラストラクチャをホストしているサーバーのクロックが、最大時間差内にあることを確認します。デフォルトでは 5 分です。 時間差が最大時間スワップを超えると、認証が成功し ません 。
Linux KRB5 キータブに、
@<KERBEROS REALM>で終わるプリンシパル名が含まれていることを確認します。 SPN を検証するには、Active Directory でsetspn -Q <spn>を実行します。正しく構成されている場合、このコマンドは SPN にアタッチされているアカウントの 1 つの識別名を返します。 Linuxでklist -k <keytab>を実行すると、<spn>@<KERBEROS REALM>がキータブに表示されます。Active Directory をKDCとして使用する場合は、MongoDB サービス アカウントがマシン アカウントではなくユーザー アカウントであることを確認します。
If you use AES encryption with Active Directory, enable AES on the MongoDB service account with either the
msDS-SupportedEncryptionTypesproperty or the "Network Security: Configure Encryption types allowed for Kerberos" policy setting.Kerberos は、同じパスワードを持つ 2 人のユーザーが異なるキーを生成するように、キー生成アルゴリズムをソルトします。 Linux と Active Directory(AD)上の
ktutilでは、ソルトの生成に同じプロセスは使用されません。 こうした不一致により、Linux と Windows の環境で連携する場合、認証が失敗する可能性があります。 この問題を軽減するには、次のことを実行します。AD サーバー上でキータブ ファイルを生成し、結果のファイルを Linux サーバーに移動します。
ktpass /out <outfile.keytab> /princ <spn>@<KERBEROS REALM> /mapuser <current userPrincipalName> /crypto ALL /ptype KRB5_NT_PRINCIPAL +rndpass 注意
これにより、
userPrincipalNameは/princの値に変更されます。Linux で
ktutilを使用し、正しいソルトを使用するように強制します。ktutilに正しいソルトを使用させるには、次の手順に従います。プリンシパル名として
userPrincipalNameを使用するキータブ エントリを生成します。ktutil: add_entry -password -p <userPrincipalName>@<KERBEROS REALM> -e aes256-cts-hmac-sha1-96 -k <KVNO> Password for <userPrincipalName>@<KERBEROS REALM>: ktutil: list -k slot KVNO Principal キーを 16 進ダンプします。
プリンシパル名として
<spn>@<KERBEROS REALM>を使用して新しいキータブ エントリを作成し、16 進数ダンプキーを使用します。1 <KVNO> <userPrincipalName>@<KERBEROS REALM>(0x<HEXDUMP>) ktutil: add_entry -key -p <spn>@<KERBEROS REALM> -e aes256-cts-hmac-sha1-96 -k <KVNO> Key for <spn>@<KERBEROS REALM> (hex): <HEXDUMP> ktutil: write_kt mongodb_ad.keytab
推奨はされませんが、Salted を使用しない RFC 4 -HMAC を使用してください。
Linux での Kerberos トレース ログ
MIT Kerberos provides the KRB5_TRACE environment variable for trace logging output. If you are having persistent problems with MIT Kerberos on Linux, you can set KRB5_TRACE when starting your mongod, mongos, or mongosh instances to produce verbose logging.
たとえば、次のコマンドは、キータブ ファイルがデフォルトの/etc/krb5.keytabパスにあるスタンドアロンのmongodを起動し、 KRB5_TRACEを/logs/mongodb-kerberos.logに書込むように設定します。
env KRB5_KTNAME=/etc/krb5.keytab \ KRB5_TRACE=/logs/mongodb-kerberos.log \ mongod --dbpath /data/db --logpath /data/db/mongodb.log \ --auth --setParameter authenticationMechanisms=GSSAPI \ --bind_ip localhost,<hostname(s)|ip address(es)> --fork
よくあるエラーメッセージ
Kerberos サービスに問題が発生した場合、状況によっては、MongoDB は GSSAPI インターフェイスからエラー メッセージを返します。 以下はよくあるエラーメッセージです。