Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why password becomes incorrect after generating keytab in Kerberos?

Tags:

kerberos

In my Kerberos system:

  1. run kinit test and input passwd, succeed.
  2. generate keytab by kadmin.local -q "xst -k test.keytab test".
  3. run kinit test and input passwd, failed:

    kinit: Password incorrect while getting initial credentials
    
  4. run kinit -k -t test.keytab test, succeed.

Is this normal ? If not, what are possible reasons?

Thanks.

like image 508
secfree Avatar asked Aug 27 '15 12:08

secfree


People also ask

Does Keytab contain password?

A keytab is a file containing pairs of Kerberos principals and encrypted keys that are derived from the Kerberos password. You can use this file to log on to Kerberos without being prompted for a password.

How does Kerberos authentication work with Keytab?

The purpose of the Keytab file is to allow the user to access distinct Kerberos Services without being prompted for a password at each Service. Furthermore, it allows scripts and daemons to login to Kerberos Services without the need to store clear-text passwords or for human intervention.

How do I find my Keytab password?

Keytab contains pairs of principal and encrypted keys (which are derived from the Kerberos password), no way to get back the password from these data. Save this answer.

How do I know if my Keytab is valid?

The contents of keytab file can be verified using either Unix/linux ktutil or klist commands or java ktab utility. Alternatively you can also use Klist or Ktab utility that comes with standard java.


3 Answers

I found that the attribute krbLastPwdChange(a timestamp value) in kerberos's database changed after I run:

kadmin.local -q "xst -k test.keytab test"

While add the option -norandkey will just create the keytab without changing password:

kadmin.local -q "xst -norandkey -k test.keytab test"

I can not find the detail document about kadmin xst.

like image 72
secfree Avatar answered Sep 28 '22 12:09

secfree


This is by design. You cannot have both a password and a keytab in Kerberos. The reason is if both were enabled, if someone was able to pull a keytab on your behalf or was in possession of a copy of your keytab, then they could masquerade as you and you would never know it. They would be able to generate a TGT via kinit.

By pulling a keytab, the password is invalidated, so if you then tried to log in with a password, you would get an error. And even if you didn't know exactly what was going on, if you reset your password, it would invalidate the keytab.

like image 23
Chris C Avatar answered Sep 28 '22 11:09

Chris C


For one simple reason:

kinit tells you that the client has not been found in the database, right? By default, when kinit is invoked with a keytab it uses the default server pricipal to obtain TGT. In your case host/<hostname>@REALM but your keytab contains a key for principal test@REALM.

I had this issue too until I have asked the MIT Kereros mailing list.

like image 34
Michael-O Avatar answered Sep 28 '22 11:09

Michael-O