【问题标题】:Certificate Auth. : the specified credentials were rejected by the server证书授权。 : 指定的凭据被服务器拒绝
【发布时间】:2022-03-03 22:23:27
【问题描述】:

自从我开始尝试通过证书身份验证方法使用 Ansible 访问我的所有 Windows 主机以来已经有好几天了。我使用脚本来配置 WinRM 并创建自签名证书。在多个主机上,它工作正常,脚本完成后我可以通过证书身份验证连接到它们,但在其他一些主机上(比如 15-20%)这是不可能的。

我收到此错误消息:

fatal: [SERVERNAME]: UNREACHABLE! => {
    "changed": false,
    "msg": "certificate: the specified credentials were rejected by the server",
    "unreachable": true
}

奇怪的是,我在 Windows 事件查看器中看不到登录事件。这是我的 WinRM 配置:

Service
    RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)(A;;GR;;;IU)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
    MaxConcurrentOperations = 4294967295
    MaxConcurrentOperationsPerUser = 1500
    EnumerationTimeoutms = 240000
    MaxConnections = 300
    MaxPacketRetrievalTimeSeconds = 120
    AllowUnencrypted = false
    Auth
        Basic = true
        Kerberos = true
        Negotiate = true
        Certificate = true
        CredSSP = true
        CbtHardeningLevel = Relaxed
    DefaultPorts
        HTTP = 5985
        HTTPS = 5986
    IPv4Filter = *
    IPv6Filter = *
    EnableCompatibilityHttpListener = false
    EnableCompatibilityHttpsListener = false
    CertificateThumbprint
    AllowRemoteAccess = true
Winrs
    AllowRemoteShellAccess = true
    IdleTimeout = 7200000
    MaxConcurrentUsers = 10
    MaxShellRunTime = 2147483647
    MaxProcessesPerShell = 25
    MaxMemoryPerShellMB = 1024
    MaxShellsPerUser = 30

监听器和证书映射都是在windows机器上配置的:

Listener
    Address = *
    Transport = HTTPS
    Port = 5986
    Hostname
    Enabled = true
    URLPrefix = wsman
    CertificateThumbprint = 927...C26E
    ListeningOn = 127.0.0.1, 172.20.x.x

CertMapping
    URI = *
    Subject = ansibleuser@localhost
    Issuer = 579f3eb1c3756339a246843f70e1a89b14fdc244
    UserName = ansibleuser
    Enabled = true
    Password

到目前为止我所尝试的:

  • 检查 LocalAccountTokenFilterPolicy 注册表项是否存在
  • 通过 winrm configSDDL default 配置对 WinRM 的访问
  • 检查 GPO
  • 更改密码(选中和取消选中密码永不过期, 等等...)
  • 创建另一个本地管理员用户
  • 启用基本和未加密的身份验证
  • 将连接类型更改为专用(无法从服务器 已加入域)
  • 运行ansible提供的脚本配置WinRM

我不明白发生了什么,这让我发疯了。以前有人遇到过这个问题吗?

我愿意接受所有建议,在此先感谢。

【问题讨论】:

    标签: ansible


    【解决方案1】:

    终于找到了解决这个问题的方法:

    基于此线程Client Certificate-based authentication stopped working for PS Remoting,我发现名为“ClientAuthTrustMode”的注册表项应设置为值“2”,然后错误消息神奇地消失了。

    这是一篇微软文章,详细介绍了密钥的含义:Overview of TLS - SSL (Schannel SSP)

    这是一个简单的 powershell 命令来翻转开关:

    Set-ItemProperty -Path registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL -Name ClientAuthTrustMode -Type DWord -Value 2
    

    希望这会帮助到那里的人。

    【讨论】:

    • 在我的情况下,会话在某些系统上运行,而不是在其他系统上运行,具有相同的证书和操作系统版本的混合。 “拒绝访问”错误消息绝对没用,我一头雾水。在我读到这个答案之前,没有任何意义,并且在经历了整整两天的地狱之后,这挽救了一天。非常感谢。
    【解决方案2】:

    感谢您的解决方案!它也解决了我的问题。

    我们有很多服务器使用基于证书的身份验证的 ansible 和 WINRM,但我们只有一台服务器与您的服务器存在相同的问题...

    我在您的共享设置中发现的唯一一个有趣的区别是: ListeningOn = 127.0.0.1, 172.20.x.x 这也和我的一样……首先是本地主机…… ListeningOn = 127.0.0.1, 19x.1xx.19.98, ::1

    我们设置中的其他服务器首先添加网络接口,如下所示: ListeningOn = 19x.16.61.38, 127.0.0.1, ::1

    我真的不知道,这是否重要,但这是我发现的唯一区别。

    非常感谢。

    【讨论】:

      猜你喜欢
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-04
      • 1970-01-01
      • 2016-10-18
      • 2016-03-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多