返回首页

Kerberos Squid 错误:加密错误和服务密钥

本文分析了 MS AD Squid 中常见的 Kerberos 认证错误:加密类型错误、服务密钥不可用、KVNO 不匹配、ICMP pinger。提供了诊断、创建 keytab、配置 krb5.conf 和权限的命令。

修复 Kerberos Squid 错误:从加密错误到 ICMP
Advertisement 728x90

解决 Squid 与 Active Directory 集成中的 Kerberos 认证错误

要高效诊断 Squid 的 Kerberos 问题,需启用详细日志。在 squid.conf 文件中添加以下配置:

debug_options ALL,1 33,2 28,2 50,2 # 认证、ACL、DNS

各模块含义:33 — 认证,28 — ACL,50 — DNS,84 — 外部 ACL 辅助工具。日志级别从 0(严重错误)到 9(完整转储)。

配置日志输出路径:

Google AdInline article slot
access_log stdio:/opt/squid/var/log/squid/access.log
cache_log stdio:/opt/squid/var/log/squid/cache.log

此设置可捕获 GSS-API 和 Negotiate 认证的详细信息,便于后续分析。

'加密类型无效' 错误解析

日志显示:

ERROR: Negotiate Authentication validating user. Result: {result=BH, notes={message=gss_accept_sec_context() failed: Unspecified GSS failure. Minor code may provide more information. Bad encryption type }}

原因:客户端缓存了使用过时密钥生成的 TGS 票据,Squid 无法解密。

Google AdInline article slot

在 PDC 模拟器上的修复步骤

  • 查找当前 PDC 模拟器:
Get-ADDomain | Select-Object PDCEmulator
  • 检查并删除旧的 SPN:
setspn -L squid
setspn -D HTTP/testSquidPc.domain.ru userAD
  • 重置 Active Directory 中的 userAD 用户密码。
  • 生成新的 keytab 文件:
ktpass /princ HTTP/[email protected] /mapuser [email protected] /crypto ALL /ptype KRB5_NT_PRINCIPAL /pass password /out C:\squid.keytab
  • 强制域内复制:
repadmin /syncall /AdeP

在 Squid 服务器上执行操作

systemctl stop squid
chown proxy:proxy /opt/squid/etc/squid.keytab
chmod 600 /opt/squid/etc/squid.keytab
klist -kte /opt/squid/etc/squid.keytab

在客户端清除缓存票据

klist purge

重启 Squid 服务:systemctl start squid。此举可绕过通常长达 10–24 小时的复制延迟。

'服务密钥不可用' 错误处理

日志内容:

ERROR: Negotiate Authentication validating user. Result: {result=BH, notes={message=gss_accept_sec_context() failed: Unspecified GSS failure. Minor code may provide more information. Service key not available }}

常见原因包括:

Google AdInline article slot
  • AD 与 keytab 之间的 KVNO(密钥版本号)不一致。
  • SPN 不匹配(FQDN 与短名称冲突)。

检查 KVNO 是否同步

在 Squid 服务器上运行:

klist -kte /opt/squid/etc/squid.keytab

输出将显示 KVNO、加密类型和主体名称。

在域控制器(PowerShell)中查询:

Get-ADUser -Identity "userAD" -Properties msDS-KeyVersionNumber | Select-Object msDS-KeyVersionNumber

使用 ktpass 命令时,通过 /vno <数字> 显式指定 KVNO,确保与 AD 一致。

测试 keytab 文件有效性

sudo -u proxy kinit -kt /opt/squid/etc/squid.keytab HTTP/testSquidPc.domain.ru

若无任何输出表示成功;若有问题,通常源于 Squid 辅助进程启动异常。

keytab 中常见的加密类型:

  • aes256-cts-hmac-sha1-96
  • aes128-cts-hmac-sha1-96
  • arcfour-hmac(旧版兼容)

配置 krb5.conf 加密策略

针对 '加密类型无效' 错误,需在 /etc/krb5.conf 中统一加密类型:

[libdefaults]
default_tgs_enctypes = aes256-cts-hmac-sha1-96
default_tkt_enctypes = aes256-cts-hmac-sha1-96
permitted_enctypes = aes256-cts-hmac-sha1-96

禁止使用 allow_weak_crypto = true。仅允许明确指定的 AES 类型,避免 keytab 包含已废弃的 DES 或 RC4 加密方式。

ICMP 探测器报错解决方案

日志提示:

pinger| Open icmp_sock: (1) Operation not permitted
ERROR: Unable to start ICMP pinger.
FATAL: Unable to open any ICMP sockets.

解决方法:赋予程序原始套接字权限:

setcap cap_net_raw+ep /opt/squid/libexec/pinger

完成后重启 Squid 服务即可正常运行。

核心要点总结

  • 启用 debug_options 33,2 实现认证流程深度追踪。
  • 使用 ktpass /vnorepadmin /syncall 确保 keytab 与 AD 的 KVNO 一致。
  • 客户端执行 klist purge 清除旧票据。
  • /etc/krb5.conf 应强制使用 AES256,禁用弱加密。
  • ICMP 功能需对 pinger 二进制文件执行 setcap cap_net_raw+ep 赋权。

— Editorial Team

Advertisement 728x90

继续阅读