Edit

Share via


Set custom password policy for SQL logins in SQL Server on Linux

Applies to: SQL Server 2025 (17.x) Preview - Linux

This article describes how you can set up and manage SQL login password policies for SQL Server on Linux.

Password policies are a crucial aspect of securing any database environment. They enforce:

  • Complexity
  • Expiration
  • Changes

This enforcement ensures that logins that use SQL Server authentication are secure.

Note

Password policies are available on Windows. For more information, see Password Policy.

Custom policy settings

Beginning with SQL Server 2025 (17.x) Preview on Linux, you can set the following configuration parameters in the mssql.conf file to enforce a custom password policy.

Configuration option Description
passwordpolicy.passwordminimumlength Defines the minimum number of characters required for a password. The passwords can be up to 128 characters long.
passwordpolicy.passwordhistorylength Determines the number of previous passwords that must be remembered.
passwordpolicy.passwordminimumage Specifies the minimum duration a user must wait before changing their password again.
passwordpolicy.passwordmaximumage Sets the maximum duration a password can be used before it must be changed.

Note

Currently, the passwordminimumlength can be set to fewer than eight characters. Your password should follow the SQL Server default password policy. By default, the password must be at least eight characters long and contain characters from three of the following four sets: uppercase letters, lowercase letters, base-10 digits, and symbols. Passwords can be up to 128 characters long. Use passwords that are as long and complex as possible.

There are two ways to configure custom password policies for SQL authentication logins in SQL Server on Linux:

Set custom password policy with adutil

In environments where policy management is centralized in an Active Directory (AD) server, ___domain administrators can set and modify the password policy values in the AD server. Additionally, the Linux machine running SQL Server must also be part of the Windows ___domain.

Use adutil to fetch the password policy from the AD server and write it to the mssql.conf file. This method offers the benefit of centralized management, and ensures consistent application of policies across the SQL Server environment.

Requirements for adutil

  1. Establish a Kerberos authenticated session

    • Run kinit with sudo to obtain or renew the Kerberos ticket-granting ticket (TGT).

    • Use a privileged account for the kinit command. The account needs to have permission to connect to the ___domain.

    In the following example, replace <user> with an account with elevated privileges in the ___domain.

    sudo kinit <user>@CONTOSO.COM
    
  2. Verify that the ticket is granted:

    sudo klist
    
  3. To update the password policy, query the ___domain with adutil:

    sudo adutil updatepasswordpolicy
    

    If the command is successful, you should see a similar message:

    Successfully updated password policy in mssqlconf.
    Restart SQL Server to apply the changes.
    

    Optionally, you can add the --path option to the previous command. You might use this option if you have the mssql-conf tool in a different ___location from the default path. The default path is /opt/mssql/bin/mssql-conf.

  4. Restart SQL Server service:

    sudo systemctl restart mssql-server
    

Set custom password policy with mssql-conf manually

You can set the SQL authentication login password policy by updating the parameters in the mssql.conf file with mssql-conf. This approach provides simplicity and direct control over the policy settings.

Use this method when the Linux host that is running SQL Server isn't part of the ___domain, and there's no ___domain controller to get the password policies from.

Run the following mssql-conf commands to set each policy configuration property.

  1. Set the minimum password length to 14 characters, adhering to the complexity requirements outlined in the Password Policy.

    sudo /opt/mssql/bin/mssql-conf set passwordpolicy.minimumpasswordlength 14
    
  2. Set the minimum password age to one day. Users can change their password after one day.

    sudo /opt/mssql/bin/mssql-conf set passwordpolicy.passwordminimumage 1
    
  3. Set the password history length to 8. Users must use eight unique passwords before reusing an old one.

    sudo /opt/mssql/bin/mssql-conf set passwordpolicy.passwordhistorylength 8
    
  4. Set the maximum password age is set to 45 days. A user can use a password for up to 45 days before the user must change it.

    sudo /opt/mssql/bin/mssql-conf set passwordpolicy.passwordmaximumage 45
    
  5. Restart SQL Server service.

    sudo systemctl restart mssql-server
    

Limitations

Currently, the minimumpasswordlength can't be set to more than 14 characters.

After updating the group password policy in Active Directory, you must manually run the adutil updatepasswordpolicy command to update mssql.conf. This command doesn't run automatically. Ensure the Linux machine running SQL Server is part of the ___domain, or manually set it using mssql-conf.

In Active Directory, each group-level password policy can be defined or undefined using a checkbox.

Screenshot of minimum password length security policy setting.

However, unchecking the policy doesn't disable it in SQL Server on Linux. To avoid applying the custom password policy, update the settings in mssql-conf instead of relying on the checkbox.