MySQL 5.7 (RHEL6.6) 使用 AD 进行 PAM 身份验证

标签 mysql authentication active-directory pam rhel6

我正在使用可插入身份验证模块 (PAM) 在 MySQL(安装在 RHEL 6.6 上)上配置 AD 身份验证。

到目前为止,我的 AD 用户可以使用 AD 凭据登录 RHEL 盒子。但是当我尝试使用 PAM 插件登录 MySQL 时,我收到“访问被拒绝”错误。 MySQL的PAM配置如下:

/etc/pam.d/mysql:
auth   required    pam_winbind.so
account required    pam_winbind.so

当我检查MySQL错误日志时,我看到authenticate_pam()方法中抛出系统错误。以下是 mysqld 日志:

entering auth_pam_server 
entering auth_pam_next_token 
auth_pam_next_token:reading at [mysql, MySQLUsers=mysql_ad], sep=[,] 
auth_pam_next_token:state=PRESPACE, ptr=[mysql, MySQLUsers=mysql_ad], out=[] 
auth_pam_next_token:state=IDENT, ptr=[mysql, MySQLUsers=mysql_ad], out=[] 
auth_pam_next_token:state=AFTERSPACE, ptr=[, MySQLUsers=mysql_ad], out=[mysql] 
auth_pam_next_token:state=DELIMITER, ptr=[, MySQLUsers=mysql_ad], out=[mysql] 
auth_pam_next_token:state=DONE, ptr=[, MySQLUsers=mysql_ad], out=[mysql] 
leaving auth_pam_next_token on /export/home/pb2/build/sb_0-19016729-1464156482.79/rpm/BUILD/mysqlcom-pro-5.7.13/mysqlcom-pro-5.7.13/plugin/pam-authentication-plugin/src/parser.c:195 
auth_pam_server:password ******** received 
auth_pam_server:pam_start rc=0 
auth_pam_server:pam_set_item(PAM_RUSER,administrator) rc=0 
auth_pam_server:pam_set_item(PAM_RHOST,localhost) rc=0 
entering auth_pam_server_conv 
auth_pam_server_conv:PAM_PROMPT_ECHO_OFF [Password: ] received 
leaving auth_pam_server_conv on /export/home/pb2/build/sb_0-19016729-1464156482.79/rpm/BUILD/mysqlcom-pro-5.7.13/mysqlcom-pro-5.7.13/plugin/pam-authentication-plugin/src/authentication_pam.c:269 
**auth_pam_server:pam_authenticate rc=4 
auth_pam_server: rc=4 
PAM error: System error** 
leaving auth_pam_server on /export/home/pb2/build/sb_0-19016729-1464156482.79/rpm/BUILD/mysqlcom-pro-5.7.13/mysqlcom-pro-5.7.13/plugin/pam-authentication-plugin/src/authentication_pam.c:441 
2016-07-18T12:48:22.360536Z 122 [Note] Access denied for user 'administrator'@'localhost' (using password: YES) 

根据上述 PAM 配置,PAM 使用 winbind 在 AD 中查找用户凭据并进行身份验证,这与在 Linux 系统中对 AD 用户进行身份验证的过程相同。当我看到 winbind 日志时,我看到以下内容:

[2016/07/18 08:27:24.236701,  5] winbindd/winbindd_pam.c:1868(winbindd_dual_pam_auth)
  Plain-text authentication for user CORPAD\administrator returned NT_STATUS_OK (PAM: 0)

这告诉我,winbind 的身份验证工作正常,但是当 winbind 将控制权返回给 PAM 时,出现故障并引发系统错误。

最佳答案

好吧,我明白了。

首先,我在这篇文章之后启用了 PAM 上的调试日志 - https://serverfault.com/questions/249671/switch-on-pam-debugging-to-syslog .

当我这样做时,我发现每次尝试进行身份验证时都会收到以下错误: PAM Audit_open() 失败:权限被拒绝

造成这种情况的根本原因是 SELinux 的强制执行。所以我禁用了SELinux并重新启动系统,这解决了这个问题。我现在可以使用 AD 凭据登录 Linux,然后使用 mysql 命令并对 mysql 进行身份验证!

关于MySQL 5.7 (RHEL6.6) 使用 AD 进行 PAM 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38437228/

相关文章:

mysql - 使用 MAX() 进行分组仍然选择其他行

Php:如何扩展库?

ruby-on-rails - 设计要求用户接受服务条款?

php - PHP 中的 date() 函数

Laravel 5 如何在访客/经过身份验证的用户上显示 Blade 内容?

Java Play2 - 从 session 到 cookie

在 ActiveDirectory 和 Sqlite3 之间复制文本数据时的 C++ 问题

active-directory - 使用 Ansible 从 LDAP 获取电子邮件

c# - Windows 身份验证登录模式不接受凭据

mysql - 在分布式系统中终止 session 的正确方法