Linux 域加入错误 - Amazon Directory Service
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

Linux 域加入错误

以下内容可帮助您排查在将 EC2 Linux 实例加入 Amazon Managed Microsoft AD 目录时可能遇到的一些错误消息。

Linux 实例无法加入域或进行身份验证

Ubuntu 14.04、16.04 和 18.04 实例必须在 DNS 中可以反向解析,然后才能使用微软 Active Directory。否则,您可能会遇到以下两种场景之一:

场景 1:Ubuntu 实例尚未加入领域

对于尝试加入领域的 Ubuntu 实例,则该 sudo realm join 命令可能不会提供加入域所需的权限并可能显示以下错误:

! Couldn't authenticate to active directory: SASL(-1): generic failure: GSSAPI Error: An invalid name was supplied (Success) adcli: couldn't connect to EXAMPLE.COM domain: Couldn't authenticate to active directory: SASL(-1): generic failure: GSSAPI Error: An invalid name was supplied (Success) ! Insufficient permissions to join the domain realm: Couldn't join realm: Insufficient permissions to join the domain

场景 2:Ubuntu 实例已加入领域

对于已经加入 Microsoft Active Directory 域的 Ubuntu 实例,尝试使用域凭据通过 SSH 连接到该实例可能会失败,并出现以下错误:

$ ssh admin@EXAMPLE.COM@198.51.100

没有此类身份:/Users/username/.ssh/id_ed25519:没有找到此文件或目录

admin@EXAMPLE.COM@198.51.100 的密码:

权限被拒绝,请重试。

admin@EXAMPLE.COM@198.51.100 的密码:

如果使用公钥登录到实例并勾选 /var/log/auth.log,您可能会看到以下有关无法找到用户的错误:

5 月 12 日 01:02:12 ip-192-0-2-0 sshd[2251]:pam_unix(sshd:auth):身份验证失败;logname= uid=0 euid=0 tty=ssh ruser= rhost=203.0.113.0

5 月 12 日 01:02:12 ip-192-0-2-0 sshd[2251]:pam_sss(sshd:auth):身份验证失败;logname= uid=0 euid=0 tty=ssh ruser= rhost=203.0.113.0 user=admin@EXAMPLE.COM

5 月 12 日 01:02:12 ip-192-0-2-0 sshd[2251]:pam_sss(sshd:auth):用户 admin@EXAMPLE.COM 已收到:10(底层身份验证模块不知道的用户)

5 月 12 日 01:02:14 ip-192-0-2-0 sshd[2251]:来自 203.0.113.0 端口 13344 ssh2 的无效用户 admin@EXAMPLE.COM 的密码失败

5 月 12 日 01:02:15 ip-192-0-2-0 sshd[2251]:已通过 203.0.113.0 [preauth] 关闭连接

但是,用户的 kinit 仍然有效。参阅此示例:

ubuntu@ip-192-0-2-0:~$ kinit admin@EXAMPLE.COM admin@EXAMPLE.COM 的密码:ubuntu@ip-192-0-2-0:~$ klist 票证缓存:FILE:/tmp/krb5cc_1000 默认委托人:admin@EXAMPLE.COM

解决办法

这两种场景当前推荐的解决方法是禁用 [libdefaults] 部分 /etc/krb5.conf 中的反向 DNS,如下所示:

[libdefaults] default_realm = EXAMPLE.COM rdns = false

无缝域加入的单向信任身份验证问题

如果您在Amazon托管的 Microsoft AD 和您的本地 Active Directory 之间建立了单向传出信任,则在尝试使用带有 Winbind 的可信 Active Directory 凭据对已加入域的 Linux 实例进行身份验证时,可能会遇到身份验证问题。

错误

Jul 31 00:00:00 EC2AMAZ-LSMWqT sshd[23832]: Failed password for user@corp.example.com from xxx.xxx.xxx.xxx port 18309 ssh2

Jul 31 00:05:00 EC2AMAZ-LSMWqT sshd[23832]: pam_winbind(sshd:auth): getting password (0x00000390)

Jul 31 00:05:00 EC2AMAZ-LSMWqT sshd[23832]: pam_winbind(sshd:auth): pam_get_item returned a password

7 月 31 日 00:05:00 ec2amaz-lsmwqt sshd [23832]:pam_winbind (sshd: auth):请求 wbcLogonUser 失败:WBC_ERR_AUTH_ERROR,PAM 错误:PAM_SYSTEM_ERR (4),NTSTATUS:**NT_STATUS_OBJECT_NAME_NOT_FOUND**,错误消息是:找不到对象名称。

Jul 31 00:05:00 EC2AMAZ-LSMWqT sshd[23832]: pam_winbind(sshd:auth): internal module error (retval = PAM_SYSTEM_ERR(4), user = 'CORP\user')

解决办法

要解决此问题,您需要使用以下步骤注释掉或从 PAM 模块配置文件 (/etc/security/pam_winbind.conf) 中删除指令。

  1. 在文本编辑器中打开 /etc/security/pam_winbind.conf 文件。

    sudo vim /etc/security/pam_winbind.conf
  2. 注释掉或删除以下指令 krb5_auth = yes

    [global] cached_login = yes krb5_ccache_type = FILE #krb5_auth = yes
  3. 停止 Winbind 服务,然后重新启动它。

    service winbind stop or systemctl stop winbind net cache flush service winbind start or systemctl start winbind