简体   繁体   English

keytab如何正常工作?

[英]How does keytab work exactly?

i have some questions on using keytab for Authentication hope the kind people here can enlightend me 我有一些关于使用keytab进行身份验证的问题,希望这里的人能够帮助我

Say, i have userA who is going to use a service running at port 1010. First, userA will login to Active Directory to authenticate himself. 比如,我有userA谁将使用在端口1010上运行的服务。首先,userA将登录到Active Directory以验证自己。

在此输入图像描述

After login, userA will try to connect to the server to use its service 1010. In order for the server to verify that UserA is who he is, I need to use setspn to register SPN at the Active Directory. 登录后,userA将尝试连接到服务器以使用其服务1010.为了使服务器验证UserA是谁,我需要使用setspn在Active Directory中注册SPN。 eg 例如

setspn -s service1010/mydomain.com serviceaccount1

Then need to generate ktab file at Active directory, eg 然后需要在Active目录下生成ktab文件,例如

ktab -a serviceprincal1010/server.domain.com@DOMAIN.COM -k mykeytab.keytab

and then bring mykeytab.keytab to the server. 然后将mykeytab.keytab带到服务器。

At the server, I would use JAAS with a login config to query the KDC eg 在服务器上,我会使用带有登录配置的JAAS来查询KDC,例如

ServicePrincipalLoginContext
{
  com.sun.security.auth.module.Krb5LoginModule required    
  principal=serviceprincal1010/server.domain.com@DOMAIN.COM 
  doNotPrompt=true useKeyTab=true keyTab=mykeytab.keytab storeKey=true;

};

From this point on, I am confused. 从这一刻起,我很困惑。 How does userA get verified (ie, userA is actually who he is? ). userA如何得到验证(即,userA实际上是谁?)。

Your diagram is wrong. 你的图表错了。 You have a basic misunderstanding about how kerberos works. 你对kerberos的运作方式有一个基本的误解。 ( It's fairly common by the way). (顺便说一句,这很常见)。 A service that uses kerberos for authentication NEVER talks to the kdc. 使用kerberos进行身份验证的服务永远不会与kdc进行通信。 All it ever does is use it's secret key ( keytab ) to decrypt blobs that are presented by the user. 它所做的只是使用它的密钥(keytab)来解密用户呈现的blob。

The only part of kerberos that ever talks to the KDC is the client or user side. 与KDC谈话的kerberos唯一的部分是客户端或用户端。 When it attempts to access the service at port 1010, it first asks the KDC for a service ticket for that service. 当它尝试在端口1010访问服务时,它首先向KDC请求该服务的服务票证。 This is a blob encrypted with the service's secret key that has the user's identity inside it. 这是一个使用服务密钥加密的blob,其中包含用户的身份。 ( plus a bunch of other protocol related stuff ). (加上一堆其他协议相关的东西)。

If you have an GSS based api inside your service on port 1010, all you need to do is tell that API where the keytab is and then ask it what the userid is on the connection. 如果您在端口1010上的服务中有基于GSS的api,那么您需要做的就是告诉密钥表所在的API,然后询问用户ID在连接上的位置。 You never need to make any other connections to external services. 您永远不需要与外部服务建立任何其他连接。 I am not familiar with the Java API's, but there should only be one or two calls required to verify the user credentials. 我不熟悉Java API,但只需要一两次调用来验证用户凭据。

While this dialogue doesn't exactly match the version of Kerberos currently in use, it will help you understand the basic principals. 虽然此对话与当前使用的Kerberos版本不完全匹配,但它将帮助您了解基本原理。

http://web.mit.edu/kerberos/dialogue.html http://web.mit.edu/kerberos/dialogue.html

To understand this, you must understand the basic principles of Kerberos, which is a "trusted third party" security system. 要理解这一点,您必须了解Kerberos的基本原理,这是一个“受信任的第三方”安全系统。

Your server will receive a "token" which the Ticket-Granting Service (TGS; basically, the Windows Domain Controller) has encrypted using the server's secret key, the one which is present in the keytab file. 您的服务器将收到一个“令牌”,票证授予服务(TGS;基本上是Windows域控制器)已使用服务器的密钥加密,该密钥是密钥表文件中存在的密钥。 The server, naturally, will need access to that secret key in order to decrypt. 当然,服务器需要访问该密钥才能解密。 If the decryption is successful, this is a guarantee to the server that the token is authentic because the secret key is known only to the TGS and the server—that's the secret these two parties share. 如果解密成功,这是服务器保证令牌是可信的,因为秘密密钥只有TGS和服务器知道 - 这是这两方共享的秘密。

The phrase "trusted 3rd party" refers to the TGS because the server (party 1) allows the user (party 2) to be authenticated because it indirectly trusts the TGS (party 3). 短语“可信第三方”指的是TGS,因为服务器(第1方)允许用户(第2方)被认证,因为它间接信任TGS(第3方)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM