I've been trying to follow this thread but admit I'm still missing
something. Given the example below, what needs to be done to get the aes
keys in the keytab, exactly?
# net ads enctypes list hostname$
'hostname$' uses "msDS-SupportedEncryptionTypes": 31 (0x0000001f)
[X] 0x00000001 DES-CBC-CRC
[X] 0x00000002 DES-CBC-MD5
[X] 0x00000004 RC4-HMAC
[X] 0x00000008 AES128-CTS-HMAC-SHA1-96
[X] 0x00000010 AES256-CTS-HMAC-SHA1-96
# samba-tool domain exportkeytab test --principal=hostname$
# klist -ke test
Keytab name: FILE:test
KVNO Principal
----
--------------------------------------------------------------------------
1 hostname$@EXAMPLE.COM (des-cbc-crc)
1 hostname$@EXAMPLE.COM (des-cbc-md5)
1 hostname$@EXAMPLE.COM (arcfour-hmac)
What version of samba are you using? For my tests i used 4.4.5. "net
enctypes" was added wth version 4.2.10.
Setting enctypes was only necessary here for aes keys with spn's as
principals. upn's/usernames always export the aes keys here.
If I 'kinit Administrator' before running your commands as root on a
DC, I get this:
klist -ke devstation.keytab
Keytab name: FILE:devstation.keytab
KVNO Principal
---- --------------------------------------------------------------------------
1 devstation$@SAMDOM.EXAMPLE.COM (arcfour-hmac)
1 devstation$@SAMDOM.EXAMPLE.COM (aes256-cts-hmac-sha1-96)
1 devstation$@SAMDOM.EXAMPLE.COM (aes128-cts-hmac-sha1-96)
1 devstation$@SAMDOM.EXAMPLE.COM (des-cbc-md5)
1 devstation$@SAMDOM.EXAMPLE.COM (des-cbc-crc)
Rowland
4.4.5 here, too.
# samba -V
Version 4.4.5
Good point, but a computer only has SPNs
Rowland
Just tested with 4.2.10 and i get your results no aes keys in export.
In above test the hostname/username was used as principal. You are right
the userPrincipalName attribute is not used for computer accounts. Still
it is possible to export an keytab for the hostname.
Ah, I wonder if Robert's AD has been upgraded to 4.4.5 ? and the
enctypes have never been added during the upgrade.
Rowland
Odd, it just works here with 4.4.5 also for hostnames even with aes
disabled in enctypes all five keys are generated.
What os are you using and how did you install samba?
Yes 'hostname' was used, but if you look carefully, there is a '$' on
the end, this make is definitely a computer.
Rowland
It's getting abit of topic doesnt it?
Of course by using the word hostname i talk about an computer account. :-)
User and Computer account both use the objectClass user the
userPrincipalName attribute belongs to that class so in theory even an
computer account may have an upn (aka userPrincipalName) defined.
It's odd that the aes keys are not exported for robert, however. Maybe
he's on gentoo and affected by it's system heimdal issues.
Yeah, sorry, I should have specified that I did exactly that -- 'kinit
Administrator' as root, on a DC -- followed by the sequence of commands
I listed.
Hm ... would domain/forest functional level matter? we've never bothered
to raise ours from the default.
That's it. On my 4.2.10 server the domain and forest level was 2003 so i
raised it to 2008 R2. Tested with an user account and at first it
exported only des and rc4 keys. After setting the password for that user
again (what rowland recommended in an other reply) it does now export
aes keys for that user. For an computer account you may have to rejoin
the computer to trigger the generation of an new password for that
account immediate.
CentOS 6.8, Samba 4.4.5 compiled from source, installed to update the
original Samba 4.3.3, also compiled from source.
It's particularly interesting (to me, at least) because the CentOS
'adcli' utility, when used to join a system to this same domain, creates
a keytab which *does* include the aes keys. But if I subsequently use
samba-tool to create a keytab for that host, those aes keys are still
absent.
Excellent, thanks. Indeed, it worked for me here, too, on a test domain.
One final (I think/hope) question: How might I deal with password resets
of the DC computer accounts themselves, to trigger the creation of their
AES keys?
The password is changed every 30 days by default if you did not disable
it via gpo.
https://blogs.technet.microsoft.com/askds/2009/02/15/machine-account-password-process-2/
See here how to reset the computer account passwords manualy.
For the samba dc's you can use
samba-tool user setpassword hostname$
Heh, sheesh, embarrassing ... as easy as that.
Thanks for your guidance! Rowland, thank you for chiming in as well!
Hmm, can be this does mess up replication.
Yes it does mess up replication! Do not use setpassword for the samba
host !!!
Glad I made an snapshot of my test vm before i tried it.
It worked for an windows 7 client hosever the LDAP and cifs tickets
where using aes256.
Reading https://wiki.samba.org/index.php/Keytab_Extraction
----- snip ----------------
Offline Keytab Creation from Secrets.tdb
If the net command fails (after all, that could be the reason for us to
start sniffing...), you can still generate a keytab without domain admin
credentials, if you can get a hold on the server's secrets.tdb. This
method can also be done offline on a different machine.
tdbdump secrets.tdb
Now look for the key SECRETS/MACHINE_PASSWORD/<domain> - the password is
the value without the trailing zero. Use the *ktutil* utility to
construct the keytab:
------ snap -------------
We do not use ktutil but use the password mentioned here for the
"samba-tool user setpassword hostname$" command.
This does not break replication and the aes keys are exported.
Ah, okay, I think I've got it, for my production domain:
- step 1: use the above tdbdump trick to identify the existing password
- step 2: use samba-tool to "reset" the password to the same value
I already reset the password of the single DC in my test domain.
Without other DCs in the picture there's effectively no harm done,
right? I do have a fairly recent samba_backup dump to use, if
necessary.
I tried to set the hosts password to something random and afterwards to
the content in secrets.tdb again. Afterwards replication was broken again.
The keyfile used for replication seems to be
/var/lib/samba/private/secrets.keytab.
It can be recreated after the password change with:
samba-tool domain exportkeytab secrets.keytab --principal=HOST/server
samba-tool domain exportkeytab secrets.keytab
--principal=HOST/server.domain.tld
samba-tool domain exportkeytab secrets.keytab --principal=SERVER$
With this new secrets.keytab replications started working on my first dc
again. But it is broken on the second one.
It's abit tricky. :-)
Been having a few other network issues in my test environment. Tried
step1/2 on both dc's and things just keep running.
After the samba-tool password reset there is usually an
WERR_NETNAME-DELETE or similar error which disapers with the next
replication.
There was no need to recreate the secrets.keytab.
There is still one difference when comparing an upgrade domain with an
fresh installed domain.
On the upgraded domain (raised function level, regenerated dc keys) when
in run klist on an connected windows client (password reset was done
with the netdom command) there are still two tickets using rc4 encryption.
#0 krbtgt/DOMAI...@DOMAIN.TLD - ticket and session encryption RC4
#1 krbtgt/DOMAI...@DOMAIN.TLD - ticket encryption RC4 and session
encryption AES256
These keys use only AES256 on my 4.4.5 test environment which ran on
2008 R2 level all the time.
So there must be an domain account whoms keys must also be regenerated.
I have no idea how to reset that.
Just to be sure i added an third dc (different site and subnet) and
reset this dc's password using the one storde on that dc in secrets.tdb.
This also worked. Here is the error message which appears once during
replication afterwards.
DC=DomainDnsZones,DC=domain,DC=tld
MUC\DC3 via RPC
DSA object GUID: [GUID]
Last attempt @ Sat Sep 17 19:26:59 2016 CEST failed,
result 64 (WERR_NETNAME_DELETED)
1 consecutive failure(s).
Last success @ Sat Sep 17 19:25:44 2016 CEST
This error propagates from dc2 to dc1 to dc3 back to dc1 and back to dc3
then it is gone.
After reading this https://adsecurity.org/?p=483 I tried to change the
krbtgt passwort using "samba-tool user setpassword krbtgt".
After that the remianing tickets using rc4 now also use aes256. Also
running "kinit Administrator; klist -e" show aes256 is used for ticket
and session encryption now.
Above article mentiones the krbtgt password is changed if the domain
level is raised from 2003 to 2008 (R2). Seems this is not the case on a
samba dc otherwise the aes encrypted keys would exist.
I resumed testing today, and I'm sort of lost again. In my test domain,
if you recall, I had done 'samba-tool user setpassword hostname$' to
reset the DC password to a new randomly-specified value. Today, I
noticed that I could no longer log on to a Win 2012 member server in
that test domain. After trying a few things and reviewing samba logs I
ended up reverting to a Samba snapshot from a time prior to the date on
which I started this exercise. All is working now, but I'm back at the
default Win 2003 functional level. Am I understanding correctly that I
should adjust the prescribed steps as follows?
- step 1: raise functional levels to 2008_R2
- step 2: use the tdbdump trick to identify the existing DC password
- step 3: use samba-tool to "reset" the DC password to that same value
- step 4: use samba-tool to reset the krbtgt password to a *new* value
Yes these where the steps I used here. Using an random password (not the
one from secrets.tdb) also resulted in an broken dc for me. Make sure
you do not include the trailing \00 used in the password field in
secrets.tdb!
Okay, thanks. And you read my mind; I'd been meaning to ask for
clarification on those samba wiki instructions: "the password is the
value without the trailing zero" (singular, with no mention of the
preceding '\').