Synopsis
MongoDB Enterprise提供mongokerberos
,用于针对运行的Kerberos部署测试 MongoDB 的Kerberos和 GSSAPI 配置选项。mongokerberos
可以用于两种模式之一:服务器和客户端。
模式 | 说明 |
---|---|
服务器 | 在服务器模式下, 分析服务器上与 Kerberos |
客户 | 在客户端模式下, |
两种模式的错误消息都包括遇到的特定错误的信息以及解决错误的潜在建议。
mongokerberos
在服务器和客户端模式下支持以下部署类型:
Linux MongoDB 客户端对受支持 Linux 平台上的 MIT Kerberos 部署进行身份验证。
Windows MongoDB 客户端对支持的 Windows 平台上的 Windows Active Directory 部署进行身份验证。
Linux MongoDB客户端对Windows Active Directory 部署进行身份验证。
注意
MongoDB Enterprise和mongokerberos
仅支持Kerberos的MIT实施。
通常,在配置与Kerberos身份验证相关的选项时,最好使用mongokerberos
验证配置。
mongokerberos
是一种测试和验证工具;它不编辑任何文件或配置任何服务。要在您的平台上配置Kerberos ,请参阅 MIT Kerberos文档 或您平台的文档。如需将MongoDB配置为使用Kerberos进行身份验证,请参考以下教程:
安装
mongokerberos
工具是MongoDB database Tools Extra包的一部分,可以与MongoDB Server一起安装,也可以独立安装。
使用MongoDB Server进行安装
要在安装mongokerberos
MongoDB EnterpriseMongoDB Server时安装 :
请按照适用于您平台的说明进行操作:安装MongoDB Enterprise MongoDB Server
完成安装后,您可以在与 相同的位置找到
mongokerberos
和其他包含的工具。MongoDB Server注意
对于 Windows
.msi
安装程序向导, Complete安装选项包括mongokerberos
。
独立安装
要将mongokerberos
作为独立安装进行安装:
点击MongoDB Enterprise的下载链接: MongoDB Enterprise下载中心
从下拉菜单中选择您的Platform (操作系统),然后根据下表选择适合您平台的Package :
OS安装包Linux
tgz
安装包Windows
zip
安装包macOS
tgz
安装包下载后,解压缩存档并将
mongokerberos
复制到硬盘上的某个位置。提示
Linux 和 macOS 用户可能希望将
mongokerberos
复制到$PATH
环境变量中定义的文件系统位置,例如/usr/bin
。 这样做可以直接在命令行上按名称引用mongokerberos
,而无需指定其完整路径,或先导航到其父目录。 有关更多信息,请参阅适用于您的平台的安装指南。
使用
mongokerberos
可以在两种模式下运行:服务器模式和客户端模式。
从系统命令行运行mongokerberos
,而不是在mongosh
中。
服务器模式
在服务器模式运行mongokerberos
会针对系统的Kerberos配置执行一系列验证步骤,包括检查 DNS 解析是否正确、验证Kerberos系统 keytab文件以及针对mongod
或mongos
的MongoDB服务主体进行测试实例。
在服务器模式下使用mongokerberos
之前,您必须:
根据平台文档在平台上配置Kerberos 。
完成这些步骤后,您可以使用--server
标志在服务器模式运行mongokerberos
,如下所示:
mongokerberos --server
如果已在服务器上正确配置Kerberos ,并且已成功创建服务主体,则输出可能如下所示:
Resolving kerberos environment... [OK] Kerberos environment resolved without errors. Verifying DNS resolution works with Kerberos service at <hostname>... [OK] DNS test successful. Getting MIT Kerberos KRB5 environment variables... * KRB5CCNAME: not set. * KRB5_CLIENT_KTNAME: not set. * KRB5_CONFIG: not set. * KRB5_KTNAME: not set. * KRB5_TRACE: not set. [OK] Verifying existence of KRB5 keytab FILE:/etc/krb5.keytab... [OK] KRB5 keytab exists and is populated. Checking principal(s) in KRB5 keytab... Found the following principals for MongoDB service mongodb: * mongodb/server.example.com@SERVER.EXAMPLE.COM Found the following kvnos in keytab entries for service mongodb: * 3 [OK] KRB5 keytab is valid. Fetching KRB5 Config... KRB5 config profile resolved as: <Your Kerberos profile file will be output here> [OK] KRB5 config profile resolved without errors. Attempting to initiate security context with service credentials... [OK] Security context initiated successfully.
最后一条消息表示系统的Kerberos配置已准备好与MongoDB一起使用。 如果配置出现任何错误,这些错误将作为上述输出的一部分显示。
客户端模式
在客户端模式下运行mongokerberos
会针对系统的 Kerberos 环境测试身份验证,执行 Kerberos 身份验证过程中的每个步骤,包括检查 DNS 解析是否正确、验证 Kerberos 客户端 keytab 文件以及测试是否可以成功授予票证。 在客户端模式下运行mongokerberos
会模拟mongosh
的客户端身份验证过程。
在以客户端模式使用mongokerberos
之前,必须首先根据平台文档在平台上配置Kerberos 。 或者,您也可以选择先在mongokerberos
服务器模式 运行 ,以验证平台的Kerberos配置在使用客户端模式之前是否有效。
完成这些步骤后,您可以在客户端模式运行mongokerberos
来测试用户身份验证,使用--client
标志,如下所示:
mongokerberos --client --username <username>
您必须提供有效的用户名,在身份验证过程中,该用户名用于请求 Kerberos 票证。 您平台的 Kerberos 基础架构必须识别此用户。
如果提供的凭证有效,并且配置文件中的Kerberos选项有效,则输出可能如下所示:
Resolving kerberos environment... [OK] Kerberos environment resolved without errors. Verifying DNS resolution works with Kerberos service at <hostname>... [OK] DNS test successful. Getting MIT Kerberos KRB5 environment variables... * KRB5CCNAME: not set. * KRB5_CLIENT_KTNAME: not set. * KRB5_CONFIG: not set. * KRB5_KTNAME: not set. * KRB5_TRACE: not set. [OK] Verifying existence of KRB5 client keytab FILE:/path/to/client.keytab... [OK] KRB5 client keytab exists and is populated. Checking principal(s) in KRB5 keytab... [OK] KRB5 keytab is valid. Fetching KRB5 Config... KRB5 config profile resolved as: <Your Kerberos profile file will be output here> [OK] KRB5 config profile resolved without errors. Attempting client half of GSSAPI conversation... [OK] Client half of GSSAPI conversation completed successfully.
最后一条消息表示已为所提供的用户成功完成客户端身份验证。 如果在身份验证步骤中遇到任何错误,这些错误将作为上述输出的一部分显示。
选项
--server
在服务器模式运行
mongokerberos
以测试平台的Kerberos配置对于与MongoDB一起使用是否有效。有关用法和预期输出的示例,请参阅服务器模式。
--client
在客户端模式运行
mongokerberos
,以根据系统的Kerberos环境测试客户端身份验证。 在客户端模式运行时,需要使用--username
指定有效的用户名。 作为验证过程的一部分,mongokerberos
将为此用户名请求Kerberos票证。 在客户端模式运行mongokerberos
会模拟mongosh
的客户端身份验证过程。有关用法和预期输出的示例,请参阅客户端模式。
--config <filename>, -f <filename>
指定运行时配置选项的配置文件。 这些选项相当于命令行配置选项。 有关更多信息,请参阅自管理配置文件选项。
mongokerberos
将从此文件中读取saslHostName
和saslServiceName
的值(如果存在)。 这些值也可以使用--setParameter
选项来指定。确保配置文件使用 ASCII 编码。
mongokerberos
实例不支持采用非 ASCII 编码(包括 UTF- 8的配置文件。
--setParameter <options>
设置可配置参数。 您可以指定多个
setParameter
字段。虽然您可以将任何支持的参数与
setParameter
一起使用,但mongokerberos
仅检查以下内容的值:如果将
--config
选项与也包含这些值的配置文件一起使用,则setParameter
值将覆盖配置文件中的值。
--host <hostname>
指定测试身份验证时要连接的 MongoDB 服务器的主机名。
如果未指定
--host
,则mongokerberos
不会对主机名执行任何 DNS验证(即 PTR记录验证)
--username <username>, -u <username>
mongokerberos
尝试 Kerberos 身份验证时使用的用户名。 在客户端模式下运行时,此值是必需的。