Security for Linked Server Connections Across Domains

By Tom Nonmacher

As database professionals, we are often required to design and implement solutions that not only maximize data accessibility and performance but also ensure data security. One such situation is when we have to establish a linked server connection between SQL Server databases that are hosted across different domains. Maintaining secure connections in these cross-domain scenarios can be challenging. However, by leveraging the features offered by SQL Server 2016, SQL Server 2017, MySQL 5.7, DB2 11.1, and Azure SQL, we can ensure that our data remains secure.

In SQL Server, linked servers allow us to connect to other SQL Server instances and other database servers such as MySQL, DB2, and Azure SQL. Typically, we use linked servers for distributed queries, which combine data from a SQL Server database with data stored in remote databases. For security purposes, it's crucial to configure the linked server with the least privileged account to prevent unauthorized access.

EXEC sp_addlinkedserver
@server=N'MyLinkedServer',
@srvproduct=N'',
@provider=N'SQLNCLI',
@datasrc=N'MyRemoteServer';
EXEC sp_addlinkedsrvlogin
@rmtsrvname=N'MyLinkedServer',
@useself=N'False',
@locallogin=NULL,
@rmtuser=N'MyRemoteUser',
@rmtpassword='MyRemotePassword';

When dealing with MySQL 5.7, we can use the Federated Storage Engine to establish a connection to a remote MySQL database. The Federated engine allows us to create a local table that is a mirror of a remote table. To secure this connection, we should use SSL to encrypt the data transmitted between the local and remote servers.

CREATE TABLE federated_table
ENGINE=FEDERATED
CONNECTION='mysql://[username]:[password]@[hostname]:[port]/[database]/[table]';

For DB2 11.1, we can establish a linked server connection to a remote DB2 database using the IBM DB2 OLE DB Provider. To secure this connection, we should use the Encrypt data transfer and Trust server certificate options in the DB2 OLE DB Provider properties. These options ensure that the data transferred between servers is encrypted, and that the server's SSL certificate is trusted.

In Azure SQL, we can use the External Data Source and External Table features to query remote databases. To secure the connection to the remote database, we should use the SHARED ACCESS SIGNATURE option in the CREATE EXTERNAL DATA SOURCE statement. This option allows us to specify a shared access signature (SAS) that is used for authentication and authorization when accessing the remote database.

CREATE EXTERNAL DATA SOURCE MyAzureBlobStorage
WITH
(
TYPE = BLOB_STORAGE,
LOCATION = 'https://myaccount.blob.core.windows.net/mycontainer',
CREDENTIAL= MyAzureBlobStorageCredential
);

In conclusion, ensuring the security of linked server connections across domains is crucial for protecting our data. By using the features provided by SQL Server 2016, SQL Server 2017, MySQL 5.7, DB2 11.1, and Azure SQL, we can establish secure linked server connections. Always remember to follow the principle of least privilege and use encryption wherever possible to further enhance the security of your data.




CB515B
Please enter the code from the image above in the box below.