Somewhere in your environment, a SQL Server service account password hasn’t changed in years. Several people know it, and it’s probably in a script or a spreadsheet. I wouldn’t be surprised if someone hasn’t even put it in an AI chat. Group managed service accounts (gMSAs) remove that problem.
This past weekend, during my Advanced Security Protection talk (online version you can watch) at Days of Data in Pittsburgh, someone asked: “What are the best practices for encrypting passwords in connection strings?” That reminded me I’m overdue to blog about Group Managed Service Accounts, so here we are, because the best way to encrypt them is to not need to encrypt them. 🙂
The Risk Hiding in Plain Sight
In our assessments, service accounts are often the least governed identities in the domain. They run SQL Server, scheduled jobs, and web applications. Because changing a password risks an outage, many never expire.
That makes them attractive targets. They are often over-privileged, rarely monitored, and unchanged for years. An attacker who steals one gets a trusted identity nobody watches.
When we add customers to our remote database managed services and set up monitoring, we encourage customers to use them, and more often than not, it raises questions about whether we should use them for our SQL Server service account.
What are Group Managed Service Accounts (gMSAs)?
A gMSA is a managed domain account that gives you automatic password management and simplified service principal name (SPN) management. It works like a standalone managed service account, but across multiple servers. Microsoft cites these benefits :
-
240-byte random passwords that resist brute-force and dictionary attacks
-
Password changes every 30 days by default, without maintenance windows
-
Deployment across server farms, such as load-balanced and clustered services
No person needs to know or store the password. That is different from saying it can never be exposed. Anyone allowed to retrieve it, including a compromised member server, can read it. gMSA passwords also derive from the domain’s KDS root key, so protect that key like any other crown-jewel secret.
A Bonus: Fewer Secrets in Connection Strings
Many teams encrypt connection strings in config files because they contain a SQL login and password. If an application runs as a gMSA and connects with Windows authentication, the string looks like Integrated Security=SSPI with no credentials in it. That leaves nothing to encrypt for that connection.
This has limits:
-
It applies only to Windows-authenticated connections. SQL logins, third-party API keys, and cloud credentials still need protection.
-
The application must run as the gMSA, and the gMSA needs a SQL Server login with least-privilege permissions.
-
Connections that hop through multiple servers may need Kerberos delegation.
-
Encrypting traffic with TLS is a separate control. Keep doing it.
What Your Team Should Do
-
Inventory every service account, with owner, privileges, and password age.
-
Start with SQL Server, IIS app pools, and scheduled tasks. Create scheduled tasks in PowerShell, because the GUI doesn’t accept a gMSA.
-
Verify that all domain controllers are patched, especially those running Windows Server 2025.
-
Restrict who can retrieve each gMSA password and who can create service accounts.
-
Grant each account only the rights it needs.
-
Record exceptions that can’t use a gMSA, and set a review date.
The commands below follow Microsoft’s documentation. Run them in a lab first.
# Once per forest (Domain or Enterprise Admin). Wait ~10 hours in production.
# Make sure to change domain name, computer objects, and Service Account Name
Add-KdsRootKey -EffectiveImmediately
# Single-DC lab only:
# Add-KdsRootKey -EffectiveTime ((Get-Date).AddHours(-10))
New-ADGroup -Name "gMSA-SQLServers" -GroupScope Global -GroupCategory Security
Add-ADGroupMember -Identity "gMSA-SQLServers" -Members "SQL01$","SQL02$"
New-ADServiceAccount -Name gmsaSQL -DNSHostName gmsaSQL.yourdomain.com `
-PrincipalsAllowedToRetrieveManagedPassword "gMSA-SQLServers" `
-KerberosEncryptionType AES256
# Reboot the servers after adding them to the group, then on each:
Install-ADServiceAccount -Identity gmsaSQL
Test-ADServiceAccount -Identity gmsaSQL
Then set the SQL Server service to YOURDOMAIN\gmsaSQL$ use a blank password using SQL Server Configuration Manager, and restart the service. Verify that SPNs are registered for Kerberos.
Next Step
Not sure how many unmanaged service accounts you have? Book a ProcureSQL assessment, and we’ll inventory them and also evaluate several other security best practices.
