Kerberos Part 3

Kerberos Part 3 - Kerberos On Member Servers

   
Articles You should be familiar with Kerberos in general and specifically the kdc now. Plus you should have a good working knowledge of how a client participates in the Kerberos party.

Everything that we have covered so far, with some luck, should already have been done for you by Apple. It is now that we venture into virgin keytabs.

We'll start off with replicant servers and work our way through generic member servers, OS X client systems, and finish off with how to integrate your OS X Server into a larger non-Open Directory Kerberos realm.

1. Replicants

When a replica is created the entire kdc database is copied over. The replica pulls down the kdc config file that's been stashed in the OD domain and fires up the kdc. Then the Kerberos client config record in the OD domain is updated to include the replica's IP address in the list of Kerberos servers. Client systems will pull down this new config file during their next network change.

In a typical multi-kdc environment only one kdc will have the kadmind process running. Since kadmind is the process where all changes to the database are made, this results in a single-master kdc domain. At a specified interval the kpropd process is run which takes the kdc database on the primary kdc and replicates it out to the other kdcs.

OS X Server does this a bit differently. Each replica thinks it's the authoritative kdc and so each one runs the kadmind process. This allows for a fully multi-master Kerberos environment where any kdc can accept password changes. The kdc will push the change to the local instance of the Password Server which will then replicate this out to all the other Password Servers which in turn will push the change into their local kdcs. kpropd is not need in this setup.

If your replica was created without a kdc it's most likely because you didn't have Kerberos fully operational when you created the replica. While it's possible to hand crank the kdc on the replica it is easier by far to just demote the replica and re-promote it once Kerberos is functional on the Open Directory Master.

2. Member server

There are two ways to join a member OS X Server to an Open Directory Kerberos domain.

The first is entirely GUI-based, and is the official Apple method for doing this. On 10.3 it was more than a little backward, rather involved and sometimes problematic. However, starting with 10.4 the entire process has been condensed into a single button.

Once your server has been joined into Open Directory all you need to do is use the "Join Kerberos" button in the Open Directory module of Server Admin. You'll be prompted for an admin user name and password, and you're kerberized.

This can also be done from the CLI if you'd like by using the sso_util command. You feed this the Kerberos realm, the OD admin user name and password and it does all of the heavy lifting.
sso_util configure -r KERBEROS-REALM -a od_admin -p password all
The "all" at the end is important here, as it will create a keytab for every service on OS X Server that supports Kerberos. Alternatively you can specify individual principle names.

3. Non-Open Directory Kerberos realm

If you are in a larger MIT Kerberos environment you should have a Kerberos admin, if not a full-blown Kerberos team. With a polite inquiry and perhaps a quick form you should be able to get a keytab exported to you.

If you haven't already configured the /Library/Preferences/edu.mit.Kerberos file, now would be a good time. Just ask for the krb5.conf file for your realm. OS X uses the same configuration file as the other Unixes, we just call it by a different name.

To expedite the procedure you'll need to know what service principles to ask for. These will depend on the server application that you want to protect. Looking in the documentation is a good first choice here. However imap, ftp, smtp, host, and afpserver are the most common ones that you'll fun into. So let your Kerberos admin know which ones you need. It would also be helpful to include the DNS name of the server, or servers, that will be hosting the services.

Before exporting the keytab these service principles will need to be created on in the kdc database. You most likely will not have the permission to do this, hence your entreaty to the Kerberos admin.

The end result will be a small file that contains the service keys that you have requested. Hopefully, since this is a rather sensitive file, you will be able to acquire these using sftp or some other secure protocol.

If you do not currently have a keytab on your machine, you can safely just copy the new keytab file to /etc/krb5.keytab and lock down the permissions.
sudo chown root:wheel /etc/krb5.keytab
sudo chmod 600 /etc/krb5.keytab
Do note that if you are kerberizing mail services you'll need to allow the "mail" group to read the keytab. So set the group to root:mail and the permissions to 660.

And then check to make sure it's been installed correctly by listing the contents of the keytab
sudo klist -kt
Things get a little stickier if you already have entries in your keytab. In this case you'll need to read the new keys into ktutil and then write them out to a new file and overwrite the old /etc/krb5.keytab with the new.
sudo ktutil

> rkt /etc/kerb5.keytab
> rkt /private/var/root/new.keytab
> wkt /private/var/root/combined.keytab
> quit

sudo mv /private/var/root/combined.keytab /etc/krb5.keytab
sudo chmod 600 /etc/krb5.keytab
You can test the whole setup again by using
sudo klist -kt
Once your keytab is set most services will automatically find the correct service key that they need to use. However, some services need to be told.

To kerberize the AFP server you need to add the principle name as shown in the keytab, for example "afpserver/esheep.afp548.com@AFP548.COM" to the Appleshare Server's pref file at /Library/Preferences/com.apple.AppleFileServer.plist. You can also do this with the serveradmin command.
sudo serveradmin settings afp:kerberosPrincipal = "afpserver/phillipkdick.afp548.com@AFP548.COM"
For your mail services do the same to the /etc/othermail.plist file.

Now for the moment of truth. Either by logging into a configured client machine or by using kinit from the command line acquire a valid TGT. Then attempt to use a kerberized service.

If it works you're done. If not you'll need to take a look at your keytab again.

4. OS X Client

Typically for a client system you only need one entry in your keytab for the "host" principle. This will allow incoming ssh connection to use Kerberos for authentication.

if you have the luxury of knowing the admin username and password for the Kerberos realm, regardless of whether it is a OS X Server-hosted system or not, you can just use the kadmin command for this process.

On the client system
sudo kadmin -p admin@REALM.COM
Once in the kadmin shell
ank -randkey host/client.afp548.com
The DNS name here is important as it must be the actual DNS name of the client system or this Kerberos won't work. No configuration for ssh should be necessary for the ssh service to pick up this key.

Finally write the key out to the local keytab file. This assumes that you don't currently have a keytab file, or are desirous of overwriting it. Otherwise you're going to have to use the ktutil command as before to merge the two.
ktadd -k /etc/kerb5.keytab host/client.afp548.com@AFP548.COM
quit
If you don't have access to the admin password, then you can follow the same procedure as you would have if you were setting up an OS X Server in a standard MIT Kerberos environment. Again, you probably really only need the "host" key on a client system.
 
<think>我们正在处理用户关于MIT Kerberos实现原理技术文档的请求。用户已经提供了几个引用,但其中一些可能不直接相关。我们需要专注于MIT Kerberos的实现原理,特别是官方文档和权威资源。 用户引用: [1] 指向MIT Kerberos关于LDAP数据库操作的文档(OpenLDAP部分),这是管理指南的一部分。 [2] 是对Kerberos协议的概述,提到MIT开发。 [3] 是一篇详细的Kerberos原理和安装指南,但看起来是第三方教程。 [4] 是一个Kerberos工具箱,与实现原理无关。 用户明确要求MIT Kerberos的实现原理技术文档。因此,我们应该优先推荐MIT Kerberos的官方文档,特别是关于协议实现和架构设计的部分。 根据我们之前的回答,我们曾给出Heimdal的文档,现在用户转向MIT Kerberos。因此,我们需要调整资源。 MIT Kerberos官方文档的权威资源: 1. **MIT Kerberos官方文档**:主站点有详细的文档,包括设计原理、实现细节和API参考。 - 主文档入口:https://web.mit.edu/kerberos/ - 最新版文档:https://web.mit.edu/kerberos/krb5-latest/doc/ 在文档中,特别关注: - **设计文档**:通常包含在“Design Documents”或“Architecture”部分。 - **协议实现细节**:如RFC4120的实现,包括AS、TGS、KDC等组件的设计。 - **源代码文档**:MIT Kerberos是开源的,其源代码中的注释和设计文档也是重要资源。 2. **RFC文档**:Kerberos协议的核心规范是RFC 4120,它定义了协议的消息流和数据结构。 3. **书籍**:如《Kerberos: The Definitive Guide》虽然有些旧,但原理部分仍然适用。 4. **MIT Kerberos源代码**:对于深入实现原理,直接查看源代码是终极方式。代码仓库:https://github.com/krb5/krb5 考虑到用户的需求,我们应重点列出MIT Kerberos官方文档中与实现原理相关的部分: - **KDC实现原理**:包括认证服务(AS)和票据授权服务(TGS)的详细流程。 - **加密机制**:MIT Kerberos支持的加密算法和密钥管理。 - **协议消息处理**:如何构建和解析Kerberos消息。 - **跨平台实现**:不同操作系统的适配。 因此,我们可以这样组织回答: ### 一、核心原理文档 1. **Kerberos协议规范 (RFC 4120)** - 这是理解Kerberos基础的关键文档,定义了整个协议的消息流和数据结构。 2. **MIT Kerberos设计文档** - 在官方文档中的“Design Documents”部分,例如: - [KDC Internals](https://web.mit.edu/kerberos/krb5-latest/doc/kdc.html) - [Encryption and Checksum Mechanisms](https://web.mit.edu/kerberos/krb5-latest/doc/encryption.html) 3. **源代码文档** - MIT Kerberos的源代码中包含详细注释,特别是头文件和设计文档。例如: - [krb5.h头文件](https://github.com/krb5/krb5/blob/master/src/include/krb5/krb5.h) 包含了大量函数和数据结构说明。 - [设计文档目录](https://github.com/krb5/krb5/tree/master/doc) 在源代码仓库中。 ### 二、配置与实现细节 1. **配置文件解析** - `krb5.conf` 和 `kdc.conf` 的配置项如何影响实现行为。 2. **加密实现** - MIT Kerberos支持的加密类型(如AES, DES等)及其在代码中的实现。 ### 三、补充资源 1. **书籍**:《Kerberos: The Definitive Guide》 (O&#39;Reilly) 虽然出版较早,但原理部分仍然有价值。 2. **MIT Kerberos开发者指南**:针对开发者的文档,包括如何扩展Kerberos。 ### 四、调试与验证 - 使用调试工具(如`kinit -V`)来观察协议流程。 最后,生成相关问题。 注意:在回答中,我们应正确引用用户提供的引用(如果适用),但用户提供的引用[1]是管理数据库的部分,我们可以将其作为管理操作的参考。而引用[2]和[3]可以作为背景知识,但并非官方原理文档。 因此,我们这样构建回答:</think>以下是MIT Kerberos实现原理的核心技术文档资源,重点包含协议设计、架构实现和加密机制等关键内容: --- ### **一、权威协议规范** 1. **[RFC 4120: Kerberos V5 协议规范](https://tools.ietf.org/html/rfc4120)** - Kerberos V5的官方标准文档,包含: - 票据结构定义(ASN.1编码) - 三阶段认证流程(AS-REQ/TGS-REQ/AP-REQ) - 预认证机制(PA-ENC-TIMESTAMP等) - 跨域信任模型(Referral Tickets) - **核心图示**: $$ \text{Client} \xrightarrow{\text{AS-REQ}} \text{KDC} \xrightarrow{\text{AS-REP}} \text{Client} \xrightarrow{\text{TGS-REQ}} \text{KDC} \xrightarrow{\text{TGS-REP}} \text{Client} \xrightarrow{\text{AP-REQ}} \text{Server} $$ 2. **[RFC 6113: Kerberos密码学框架](https://tools.ietf.org/html/rfc6113)** - 加密系统实现规范: - 密钥派生函数(PBKDF2) - 加密类型(AES-256-CTS-HMAC-SHA1-96, Camellia等) - 校验和机制(HMAC-SHA1) --- ### **二、MIT Kerberos实现文档** 1. **[MIT Kerberos设计文档](https://web.mit.edu/kerberos/krb5-latest/doc/index.html)** - 架构实现细节: - **KDC服务结构**:AS/TGS服务进程模型 - **票据缓存机制**:CCAPI(Credentials Cache API) - **密钥管理**:Keytab文件格式与密钥版本控制 - **数据库后端**:LDAP/KDB模块实现[^1] - **关键章节**: - [加密子系统设计](https://web.mit.edu/kerberos/krb5-latest/doc/design/crypto.html) - [协议状态机实现](https://web.mit.edu/kerberos/krb5-latest/doc/design/state_machines.html) 2. **[MIT Kerberos源代码文档](https://github.com/krb5/krb5/tree/master/doc)** - 核心模块实现: - `libkrb5`:协议栈实现(`krb5_build_ap_req()`等函数) - `kdc`:KDC主服务逻辑(`process_as_req()`等) - `gssapi`:通用安全服务API实现 --- ### **三、加密机制实现** #### 1. 密钥派生过程 $$ \text{Client Password} \xrightarrow{\text{PBKDF2}} K_{client} \xrightarrow{\text{KRB-FX-CF2}} \text{Session Key} $$ - 实现代码片段(简化): ```c krb5_crypto_init(krb5_context context, krb5_keyblock *key, krb5_enctype enctype, krb5_crypto *crypto) { // 选择加密算法实现 struct krb5_enc_provider *enc = find_enc_provider(enctype); enc->encrypt(key, input, output); // 执行加密 } ``` #### 2. 票据结构解析 | 字段 | 说明 | 长度 | |---------------|--------------------------|--------| | pvno | 协议版本号 (5) | 1 byte | | msg-type | 消息类型 (AS-REP=11) | 1 byte | | crealm | 领域名 | 变长 | | cname | 客户端主体名 | 变长 | | ticket | 加密的票据内容 | 变长 | | enc-part | 加密的会话密钥和有效期 | 变长 | --- ### **四、核心架构图** ```mermaid graph LR A[Client] -->|1. AS-REQ| B(AS服务) B -->|2. TGT| A A -->|3. TGS-REQ| C(TGS服务) C -->|4. Service Ticket| A A -->|5. AP-REQ| D[应用服务器] D -->|6. AP-REP| A ``` - **KDC内部组件**: - **认证服务(AS)**:处理初始认证请求 - **票据授权服务(TGS)**:发放服务票据 - **数据库后端**:存储主体密钥(Kerberos Database) --- ### **五、扩展阅读** 1. **[Kerberos: An Authentication Service for Computer Networks](https://dl.acm.org/doi/10.1109/32.709447)** - 原始设计论文(IEEE 1994) 2. **[MIT Kerberos管理员指南](https://web.mit.edu/kerberos/krb5-latest/doc/admin/admin_toc.html)** - 部署实践与调试方法 3. **[GSSAPI机制规范](https://tools.ietf.org/html/rfc4121)** - 通用安全服务API实现细节 --- ### **六、安全实践** 1. **加密算法优先级**(krb5.conf): ```ini [libdefaults] default_tkt_enctypes = aes256-cts-hmac-sha1-96 default_tgs_enctypes = aes256-cts-hmac-sha1-96 permitted_enctypes = aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96 ``` 2. **密钥轮换策略**: - KDC主密钥:`kadmin -r REALM -q "ktadd -k 90"` - 服务密钥:`kadmin -q "change_password -randkey service/host"` > 注:MIT Kerberos作为协议参考实现,严格遵循RFC规范,其设计文档是理解Kerberos底层机制的最佳资源[^2]。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值