This article provides an example of how to prepare a machine key for SQL Server running on Linux in a contained availability group (AG).
A contained AG is an availability group that supports:
Managing metadata objects (users, logins, permissions, SQL Server Agent jobs, and so on) at the AG level in addition to the instance level.
Specialized contained system databases within the AG.
The examples in this article target SQL Server in Linux containers, but you can use the same steps for SQL Server on Linux, running on physical machines, virtual machines, and in a Kubernetes-based deployment.
Caution
These instructions should only be used for contained availability groups. When you configure a contained AG with a common machine key across all replicas, first ensure there's no existing encryption hierarchy (for example, transparent data encryption, column-level encryption, or any other security-related feature that requires key management). Changing the machine key could break the encryption and cause data loss. After configuration, avoid creating or modifying the encryption hierarchy for security reasons.
Overview of the machine key
In SQL Server on Linux, the machine key plays a vital role in securing communication and data.
The following table describes its primary functions.
Function
Description
Encryption and decryption
The machine key is used to encrypt and decrypt data exchanged between nodes in an AG
Authentication
It helps in authenticating communication between the primary and secondary replicas in an AG
Security
The machine key and associated certificates must be protected to prevent unauthorized access
When you work with SQL Server 2022 (16.x) on Linux and contained AGs, you must synchronize the machine keys between SQL Server replicas. This process allows the service master key (SMK) in the contained master database to be used for decrypt and encrypt operations.
Prepare SQL Server container on standalone host to run custom machine key
The following instructions show an example of generating a new machine key in base64 format.
Generate a machine key file using OpenSSL (into a file called machine-key.bin) using the following script.
You can use the same steps across all the SQL Server container deployments that you intend to use as replicas in your contained AG. You must use the same machine key, and don't generate different machine keys for each of the SQL Server container deployments.
SQL Server now runs on your choice of operating system. In this learning path, you'll discover the fundamentals of SQL Server on Linux, before discovering how to run SQL Server on Linux containers and deploy SQL Server on Linux. You'll then learn how to automatically tune your SQL Server on Linux deployment.
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.