CentOS Wiki
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • FrontPage
  • Documentation
  • TipsAndTricks
  • HowTos
  • FAQ
  • Events
  • Contribute
  • RecentChanges

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

  • zh
  • HowTos
  • HttpKerberosAuth

在 apache httpd 内采用 Kerberos 进行验证

你果你拥有一台 Kerberos 或 Active Directory 的安装,你或许会想在 apache httpd 内采用 Kerberos 进行验证及单一登录。 这份教学文档假设你已经有一台运作中的 kerberos 服务器,或者如 zh/TipsAndTricks/WinbindADS 般采用 winbindd 整合了 active directory。

这份教学文档只供 CentOS 5 使用。CentOS 4 在 httpd-config 内需要稍微不同的选项。

1. Keytab

要在 apache httpd 内使用 kerberos 进行验证,在你执行 apache httpd 的机器上的 keytab 档内需要有一项服务的主记录。这里的所有描述都采用位於 /etc/krb5.keytab 的总体 keytab 档。基於安全理由,你或许会给每个服务一个 keytab 档,好叫服务甲不能阅读服务乙的 keytab 信息。apache httpd 的 kerberos 模块缺省使用的服务原则名叫 HTTP。

1.1. 清一色 kerberos

要以 kadmin 加入一个服务原则,在执行 apache httpd 的机器上引导 kadmin 并使用这个指令

ktadd HTTP/$HOST@$REALM

当中 $HOST 是这台机器的完整域名,而 $REAL 是你的 kerberos 域名。假如你有意使用另一个服务名称,请亦取替 HTTP。

1.2. winbindd

如果你使用 winbindd,请使用以下指令来创建 keytab,并在你的 keytab 内加入服务原则:

net ads keytab create
net ads keytab add HTTP

之后你可以发出这个指令来检查你的 keytab

klist -k

它应该列出最少 2 行,包括 host/$HOST@$REALM 及 HTTP/$HOST@$REALM 的原则。

2. 设置 apache httpd

除了 krb5-workstation 这个组件外,你亦需要 mod_auth_kerb 这个组件。一旦你安装了它,你便可以在合适的 http 段落里(<Directory> 或 <Location>)设置验证。 这个配置文件有以下模样:

    <Location />
        AuthName "Restricted Access"
        AuthType Kerberos
        Krb5Keytab  /etc/krb5.keytab
        KrbAuthRealms $REALM
        KrbMethodNegotiate On
        KrbMethodK5Passwd On
        require valid-user
    </Location> 

很明显你需要以你的 kerberos 本地来取代 $REALM。如果有非 kerberos 的系统进行访问的话,你需要设置 KrbMethodK5Passwd 为 On 来采用口令作后备方法。

3. 单一登录

3.1. Internet Explorer

假若你的 kerberos 本地等同你的 Active Directory 本地,Internet explorer 会自动尝试以 kerberos 登录。

3.2. Firefox

在 firefox 的位置列内输入 about:config 并编辑 network.negotiate-auth.trusted-uris 这个项目,输入 apache httpd 服务器的机名,或 .domain.tld 来容许这个本地内的所有服务器采用 kerberos。

4. 侦错

如果运作上出现问题,请利用 klist 来确定你在客户端拥有一张有效的 kerberos 通行票。借着将 LogLevel 设置为 debug 来引导 apache httpd 服务器上的侦错日志,输出便可以在 apache httpd 的故障日志中找到。

Translation of revision 3

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01