If you've ever cloned a Windows virtual machine or used a disk image to spin up multiple machines quickly, you've probably run into some baffling authentication failures. Users can't log in, services refuse to start, and your event logs are full of Kerberos and NTLM errors that seem to point in every direction at once. Nine times out of ten, the root cause is the same: duplicate Security Identifiers, or SIDs. In this guide, I'll walk you through exactly what duplicate SIDs are, why they break authentication, and, most importantly, how to fix them step by step.
What Are SIDs and Why Do They Matter?
Every Windows machine, user account, and security group gets assigned a unique Security Identifier when it's created. A SID looks something like this: S-1-5-21-3623811015-3361044348-30300820-1013. That long string is how Windows internally identifies everything, not by name, but by this unique number. When your machine wants to authenticate a user or authorize access to a resource, it checks SIDs, not usernames.
When you clone a virtual machine or deploy from a template without properly running Sysprep, the cloned machine carries the same SID as the original. You now have two, or potentially dozens, of machines with identical SIDs on the same network. From Windows' perspective, these machines are the same machine. The result is authentication chaos.
Both Kerberos and NTLM rely on SIDs during the authentication process. Kerberos tickets contain SID information for authorization, and NTLM uses SIDs to build access tokens. When multiple machines share a SID, the domain controllers and the machines themselves get confused about identity, trust, and authorization, and authentication starts failing in ways that are incredibly hard to diagnose without knowing the root cause.
How Duplicate SIDs Break Kerberos and NTLM Authentication
Let me explain the mechanics so you understand exactly what's happening under the hood, this will help you diagnose the problem much faster when you see it in the wild.
Kerberos Authentication Failures
Kerberos is the primary authentication protocol in Active Directory environments. It works on the basis of tickets issued by a Key Distribution Center (KDC), which is your domain controller. When a user on Machine A tries to access a resource on Machine B, the KDC issues a service ticket. That ticket includes the SID of the requesting user and machine.
When Machine A and Machine C share the same machine SID, the KDC can get confused about which machine is actually making the request. More critically, if those machines are joined to the domain and their computer accounts have overlapping SID-related attributes, the ticket validation process fails. You'll see events like Event ID 4 (Kerberos) in the system log, or the dreaded KDC_ERR_C_PRINCIPAL_UNKNOWN error. Services that use Kerberos for mutual authentication, like SQL Server, IIS with Windows Authentication, or SharePoint, will simply refuse connections.
NTLM Authentication Failures
NTLM is the fallback protocol and is also used in workgroup environments, older applications, and certain cross-forest scenarios. NTLM uses the machine's SID as part of building the NTLM security blob during the challenge-response handshake. When the SID is duplicated, resource servers may cache access tokens tied to the SID and then incorrectly apply them to the wrong machine. You'll see Event ID 4625 (failed logon) with logon type 3 (network logon), often accompanied by error code 0xC000006D (wrong username or authentication information) or 0xC0000064 (user name doesn't exist).
The Domain Trust Angle
Domain trusts are also SID-based. If two machines in your environment share a SID, SID filtering, a security feature that protects against SID spoofing across trusts, may start blocking legitimate authentication requests. This makes cross-domain authentication fail even when credentials are perfectly valid. This is one of the nastier side effects, because it looks exactly like a trust or DNS problem rather than a SID issue.
Diagnosing the Problem: Is It Actually a Duplicate SID?
Before you start making changes, confirm that duplicate SIDs are the actual problem. Here's how to check.
Open PowerShell as Administrator on the suspected machines and run the following command to retrieve the machine SID:
$sid = (Get-WmiObject Win32_ComputerSystem).Name
$objSID = New-Object System.Security.Principal.NTAccount($sid)
[System.Security.Principal.SecurityIdentifier]::new(
[System.Security.Principal.WellKnownSidType]::LocalSystemSid, $null
)
A more reliable method is to use the PsGetSid tool from Sysinternals (part of the PsTools suite). Download it from the official Microsoft Sysinternals page and run:
psgetsid \\MachineName
Run this on each machine you suspect. If two or more machines return the same SID, you've found your culprit.
On the affected machines and on your domain controller, open Event Viewer and check the following logs:
- System log, Look for Kerberos errors (Source: Kerberos, Event IDs 4, 7, 14)
- Security log, Look for Event ID 4625 (failed logons) and Event ID 4771 (Kerberos pre-authentication failed)
- Directory Service log, On domain controllers, look for replication errors or authentication-related warnings
You can filter the Security log quickly with PowerShell:
Get-WinEvent -FilterHashtable @{
LogName = 'Security'
Id = 4625, 4771, 4776
StartTime = (Get-Date).AddDays(-1)
} | Select-Object TimeCreated, Id, Message | Format-List
Enable Netlogon debug logging to capture detailed NTLM failure information. Run this on the machine experiencing the failures:
nltest /dbflag:0x2080ffff
Then try the failing authentication. Review the log at C:\Windows\debug\netlogon.log. Look for entries that mention SID conflicts or "duplicate SID" messages. Disable the logging after you're done:
nltest /dbflag:0x0
Step-by-Step Fix: Resolving Duplicate SIDs
Now that you've confirmed duplicate SIDs are the problem, here's how to fix them. The approach depends on whether the affected machines are already domain-joined or still in a workgroup.
The cleanest way to resolve a duplicate SID situation is to run Sysprep on each cloned machine. Sysprep reseals the operating system, generates a new unique SID, and clears machine-specific identifiers. This is the method Microsoft officially recommends.
On the affected machine, open an elevated command prompt and run:
C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe /reboot
The /generalize switch removes all unique system information including the SID. The /oobe switch puts the machine into Out-of-Box Experience mode on restart, where it will generate a fresh SID. The /reboot switch restarts automatically.
After the machine restarts and you complete the OOBE setup, you'll need to rejoin it to the domain. Before doing so, remove the old stale computer account from Active Directory if it still exists with the same name:
- On a domain controller, open Active Directory Users and Computers
- Find the computer account for the affected machine
- Right-click and select Delete, then confirm
- On the newly Sysprep'd machine, go to Settings > System > About > Domain or Workgroup
- Click Change and rejoin the domain with appropriate credentials
Alternatively, use PowerShell to rejoin:
$credential = Get-Credential # Enter domain admin credentials
Add-Computer -DomainName "yourdomain.com" -Credential $credential -Restart
In older environments where running Sysprep isn't practical, for instance, machines with specialized software that can't survive a Sysprep cycle, you can use NewSID from Sysinternals to change the machine SID without a full Sysprep. However, I need to be upfront with you: Microsoft has stated that changing the machine SID post-deployment using third-party tools is not supported and NewSID has been retired from the Sysinternals suite. Microsoft's official position is that the machine SID is not used for anything that would cause problems in a domain environment (only local accounts use the machine SID as a base).
That said, if you're dealing with a workgroup environment or older Windows versions where authentication issues persist, some administrators still use this approach as a last resort. If you go this route, document it carefully and test thoroughly before rolling it out broadly.
After you've resolved the SID duplication, old Kerberos tickets may still be cached on client machines. These stale tickets can continue causing authentication failures even after the SID issue is fixed. Purge them with:
klist purge
Run this on affected client machines. For domain controllers, you may also want to restart the Kerberos Key Distribution Center service:
Restart-Service kdc
NTLM caches credentials and access tokens that may be stale after a SID change. Clear the cached credentials using Credential Manager:
cmdkey /list
This shows all cached credentials. Remove the ones associated with the affected machines:
cmdkey /delete:MachineName
You can also clear all Windows cached credentials via Control Panel > User Accounts > Credential Manager > Windows Credentials and remove entries tied to the affected machines.
After cleaning up SIDs and tickets, restart the key authentication-related services. On the domain controllers:
Restart-Service NTDS
Restart-Service KDC
Restart-Service Netlogon
On the affected member machines:
Restart-Service Netlogon
Restart-Service LanmanWorkstation
Restart-Service LanmanServer
In many cases, a full reboot of the affected machines and domain controllers is the cleanest way to ensure all stale state is cleared.
Advanced Troubleshooting: When the Basic Fix Doesn't Work
Sometimes you've run Sysprep, rejoined the domain, purged tickets, and authentication is still failing. Here's what to check next.
Check for SID History Conflicts
Active Directory stores a SID History attribute on user and computer accounts. This attribute is used during domain migrations to preserve access to old resources. If a cloned machine was once migrated or if SID history was somehow populated with conflicting SIDs, authentication can still fail after Sysprep. Check SID history with PowerShell:
Import-Module ActiveDirectory
Get-ADComputer -Identity "MachineName" -Properties SIDHistory | Select-Object Name, SID, SIDHistory
If you see unexpected entries in SIDHistory, work with your domain administrator to clean them up. Be cautious, removing SID history entries can break access to resources for migrated accounts.
Investigate DNS and SPNs
Kerberos authentication depends heavily on DNS. When machines are cloned, they sometimes end up with duplicate DNS registrations. Kerberos uses Service Principal Names (SPNs) to identify services, and duplicate SPNs are a very common cause of Kerberos failure even after SID issues are resolved.
Check for duplicate SPNs across your domain:
setspn -X -F
This scans the entire forest for duplicate SPNs. Any duplicates found must be resolved, typically by deleting the SPN from the old or incorrect computer account:
setspn -D "HTTP/OldMachineName.domain.com" OldMachineName
Verify DNS Records
Stale DNS records from the cloned machines can cause Kerberos to send tickets to the wrong machine. Check for duplicate A records in your DNS server for the affected machines:
nslookup MachineName.yourdomain.com
If you see multiple IP addresses returned for one machine name, clean up the stale DNS records through DNS Manager on your DNS server, or use:
dnscmd /recorddelete yourdomain.com MachineName A /f
Check the Secure Channel
After Sysprep and domain rejoin, verify the secure channel between the machine and the domain controller is healthy:
nltest /sc_verify:yourdomain.com
If the secure channel is broken, reset it:
nltest /sc_reset:yourdomain.com
Or with PowerShell:
Test-ComputerSecureChannel -Repair -Credential (Get-Credential)
Review Group Policy Application
Duplicate SIDs can corrupt the Group Policy cache. If authentication works but GPO isn't applying correctly after your fix, clear the GP cache:
rd /s /q "%windir%\system32\GroupPolicy"
rd /s /q "%windir%\system32\GroupPolicyUsers"
gpupdate /force
Analyze Kerberos Tickets in Detail
If you need to dig deeper into what Kerberos is actually doing, use the klist command to inspect current tickets:
klist tickets
Look at the client principal names and the service names in the tickets. If you see tickets referencing unexpected machine names or SIDs, it confirms stale ticket caching is still the problem. Purge and re-authenticate.
For even deeper analysis, enable Kerberos operational logging:
wevtutil sl Microsoft-Windows-Kerberos/Operational /e:true
Then review the log in Event Viewer under Applications and Services Logs > Microsoft > Windows > Kerberos > Operational.
Prevention: How to Never Deal with This Again
Fixing duplicate SIDs is painful. Preventing them is easy if you build the right habits into your VM deployment process.
Always Run Sysprep Before Cloning
This is the number-one rule. Before you create a VM template, golden image, or any image you intend to clone, run Sysprep with the /generalize flag. This removes the SID from the template so that every machine deployed from it gets a fresh, unique SID on first boot.
sysprep.exe /generalize /oobe /shutdown
Using /shutdown instead of /reboot shuts the machine down after generalization, which is what you want for templates, you don't want the template to boot back up and generate a new SID for itself before you capture the image.
Use Unattend.xml for Automated Deployments
For large-scale deployments using WDS, MDT, or SCCM/Endpoint Configuration Manager, use an unattend.xml answer file that includes Sysprep settings. This ensures every deployed machine goes through the generalization process automatically and never ends up with a duplicate SID.
Validate Deployments with Automated SID Checks
Build a post-deployment validation script that checks for SID uniqueness across your environment. Run it as part of your deployment pipeline:
$computers = Get-ADComputer -Filter * -Properties SID
$sids = $computers | Group-Object -Property SID
$duplicates = $sids | Where-Object { $_.Count -gt 1 }
if ($duplicates) {
Write-Warning "Duplicate SIDs found!"
$duplicates | ForEach-Object {
Write-Output "SID: $($_.Name)"
$_.Group | ForEach-Object { Write-Output " - $($_.Name)" }
}
} else {
Write-Output "All SIDs are unique. No issues detected."
}
Use Virtual Machine Templates Properly
If you're using VMware vSphere, Hyper-V, or a cloud platform like Azure or AWS, use the platform's native templating and customization features rather than simple disk cloning. vSphere's Guest Customization Specifications, for instance, run Sysprep automatically during deployment. Azure's VM generalization process (waagent -deprovision on Linux, Sysprep on Windows) does the same. Use these features, they exist exactly to solve this problem.
Document Your Clone Policy
Create a written policy for your team that explicitly states: no VM may be deployed from a clone or template unless it has been properly generalized. Make this part of your change management process. A policy that lives in documentation is far less painful than an incident that takes down authentication for your entire environment.
Frequently Asked Questions
/generalize before capturing. When you deploy from a generalized image in Azure, the platform's Guest Agent handles the OOBE process and generates a fresh SID automatically. If you've already deployed VMs from a non-generalized image on Azure, you'll need to run Sysprep on each affected VM, then re-register it with the domain. Azure's VM Custom Script Extension or Azure Automation can help you do this at scale.klist purge and retry. If that doesn't help, check for duplicate SPNs using setspn -X -F and resolve any conflicts. Also verify that DNS is resolving correctly and that there are no stale DNS records pointing to old IP addresses. Check the secure channel between the client and the domain controller with nltest /sc_verify:domain. Finally, review the Security event log for specific error codes, 0xC000006D, 0xC000006E, and 0xC0000064 each point to slightly different authentication failure modes and can guide you to the specific remaining issue.Summary
Duplicate SIDs are one of those problems that are completely preventable but absolutely maddening when you're in the middle of them. The root cause is almost always the same: VMs or disk images cloned without running Sysprep first. The symptoms, Kerberos ticket failures, NTLM authentication errors, Event ID 4625 flooding your security log, look like they could come from a dozen different causes, which is why the diagnosis step is so important.
To recap the remediation path: confirm duplicate SIDs with PsGetSid, run Sysprep on the affected machines with the /generalize flag, clean up stale computer accounts and DNS records, rejoin the domain, purge Kerberos tickets, and restart authentication services. If problems persist, dig into SPNs, SID history, the secure channel, and the Group Policy cache.
Going forward, make Sysprep before cloning a non-negotiable part of your deployment process. Use platform-native templating features that handle generalization automatically. Build SID uniqueness checks into your post-deployment validation. These habits will save you from ever spending another afternoon chasing authentication errors back to a 30-second step someone skipped when they were in a hurry.
If you're still stuck after working through everything in this guide, check your event logs for specific Kerberos error codes and reference Microsoft's Kerberos troubleshooting documentation. The error codes are specific enough that they'll point you to the remaining problem pretty directly. You've got this.