Skip to content

Commit cd7917c

Browse files
committed
Update docs/azure-data-studio/enable-kerberos.md
1 parent 10b63c8 commit cd7917c

1 file changed

Lines changed: 58 additions & 31 deletions

File tree

docs/azure-data-studio/enable-kerberos.md

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ title: Connect your SQL Server instance using Windows authentication (Kerberos)
33
description: Learn how to connect Azure Data Studio to your SQL Server instance by using Microsoft Kerberos integrated authentication.
44
author: markingmyname
55
ms.author: maghan
6-
ms.reviewer: alayu
7-
ms.date: 05/03/2021
6+
ms.reviewer: alayu, randolphwest
7+
ms.date: 06/15/2023
88
ms.service: azure-data-studio
99
ms.topic: how-to
1010
---
11-
1211
# Connect Azure Data Studio to SQL Server using Kerberos
1312

1413
Azure Data Studio supports connecting to SQL Server by using Kerberos.
@@ -20,41 +19,47 @@ To use integrated authentication (Windows Authentication) on macOS or Linux, you
2019
To get started, you need:
2120

2221
- Access to a Windows domain-joined machine to query your Kerberos domain controller.
22+
2323
- SQL Server should be configured to allow Kerberos authentication. For the client driver running on Unix, integrated authentication is supported only by using Kerberos. For more information, see [Using Kerberos integrated authentication to connect to SQL Server](../connect/jdbc/using-kerberos-integrated-authentication-to-connect-to-sql-server.md). There should be [service principal names (SPNs)](/windows/win32/ad/service-principal-names) registered for each instance of SQL Server you're trying to connect to. For more information, see [Register a Service Principal Name for Kerberos Connections](../database-engine/configure-windows/register-a-service-principal-name-for-kerberos-connections.md).
2424

2525
## Check if SQL Server has a Kerberos setup
2626

27-
Sign in to the host machine of SQL Server. From the Windows command prompt, use `setspn -L %COMPUTERNAME%` to list all the SPNs for the host. Verify there are entries that begin with MSSQLSvc/HostName.Domain.com. These entries mean that SQL Server has registered an SPN and is ready to accept Kerberos authentication.
27+
Sign in to the host machine of SQL Server. From the Windows command prompt, use `setspn -L %COMPUTERNAME%` to list all the SPNs for the host. Verify there are entries that begin with `MSSQLSvc/HostName.contoso.com`. These entries mean that SQL Server has registered an SPN and is ready to accept Kerberos authentication.
2828

2929
If you don't have access to the host of the SQL Server instance, then from any other Windows OS joined to the same Active Directory, you could use the command `setspn -L <SQLSERVER_NETBIOS>`, where *<SQLSERVER_NETBIOS>* is the computer name of the host of the SQL Server instance.
3030

3131
## Get the Kerberos Key Distribution Center
3232

3333
Find the Kerberos Key Distribution Center (KDC) configuration value. Run the following command on a Windows computer that's joined to your Active Directory domain.
3434

35-
Start `cmd.exe` and run `nltest`.
35+
Run `nltest` from the command line, and replace "DOMAIN.CONTOSO.COM" with your domain's name.
3636

37+
```console
38+
nltest /dsgetdc:DOMAIN.CONTOSO.COM
3739
```
38-
nltest /dsgetdc:DOMAIN.COMPANY.COM (where "DOMAIN.COMPANY.COM" maps to your domain's name)
3940

40-
Sample Output
41-
DC: \\dc-33.domain.company.com
41+
Output is similar to the following sample:
42+
43+
```output
44+
DC: \\dc-33.domain.contoso.com
4245
Address: \\2111:4444:2111:33:1111:ecff:ffff:3333
4346
...
4447
The command completed successfully
4548
```
46-
Copy the DC name that's the required KDC configuration value. In this case, it's dc-33.domain.company.com.
49+
50+
Copy the DC name that's the required KDC configuration value. In this case, it's dc-33.domain.contoso.com.
4751

4852
## Join your OS to the Active Directory domain controller
4953

50-
### Ubuntu
54+
### [Ubuntu](#tab/ubuntu)
55+
5156
```bash
5257
sudo apt-get install realmd krb5-user software-properties-common python-software-properties packagekit
5358
```
5459

55-
Edit the `/etc/network/interfaces` file so that your Active Directory domain controller's IP address is listed as dns-nameserver. For example:
60+
Edit the `/etc/network/interfaces` file so that your Active Directory domain controller's IP address is listed as `dns-nameserver`. For example:
5661

57-
```/etc/network/interfaces
62+
```output
5863
<...>
5964
# The primary network interface
6065
auto eth0
@@ -63,7 +68,7 @@ dns-nameservers **<AD domain controller IP address>**
6368
dns-search **<AD domain name>**
6469
```
6570

66-
> [!NOTE]
71+
> [!NOTE]
6772
> The network interface (eth0) might differ for different machines. To find out which one you're using, run ifconfig and copy the interface that has an IP address and transmitted and received bytes.
6873
6974
After editing this file, restart the network service:
@@ -74,25 +79,32 @@ sudo ifdown eth0 && sudo ifup eth0
7479

7580
Now check that your `/etc/resolv.conf` file contains a line like the following one:
7681

77-
```Code
82+
```output
7883
nameserver **<AD domain controller IP address>**
7984
```
8085

86+
Join to the Active Directory domain:
87+
8188
```bash
8289
sudo realm join contoso.com -U 'user@CONTOSO.COM' -v
90+
```
91+
92+
Here's the expected output:
93+
94+
```output
8395
<...>
8496
* Success
8597
```
86-
87-
### RedHat Enterprise Linux
98+
99+
### [RedHat Enterprise Linux](#tab/rhel)
88100

89101
```bash
90102
sudo yum install realmd krb5-workstation
91103
```
92104

93105
Edit the `/etc/sysconfig/network-scripts/ifcfg-eth0` file (or other interface config file as appropriate) so that your Active Directory domain controller's IP address is listed as a DNS server:
94106

95-
```/etc/sysconfig/network-scripts/ifcfg-eth0
107+
```output
96108
<...>
97109
PEERDNS=no
98110
DNS1=**<AD domain controller IP address>**
@@ -104,64 +116,79 @@ After editing this file, restart the network service:
104116
sudo systemctl restart network
105117
```
106118

107-
Now check that your `/etc/resolv.conf` file contains a line like the following one:
119+
Now check that your `/etc/resolv.conf` file contains a line like the following one:
108120

109-
```Code
121+
```output
110122
nameserver **<AD domain controller IP address>**
111123
```
112124

125+
Join to the Active Directory domain:
126+
113127
```bash
114128
sudo realm join contoso.com -U 'user@CONTOSO.COM' -v
129+
```
130+
131+
Here's the expected output:
132+
133+
```output
115134
<...>
116135
* Success
117-
118136
```
119137

120-
### Configure KDC in krb5.conf with macOS
138+
### [Configure KDC in krb5.conf with macOS](#tab/mac)
121139

122140
This section discusses the [Kerberos configuration file](http://web.mit.edu/macdev/KfM/Common/Documentation/preferences-osx.html).
123141

124142
Edit the `/etc/krb5.conf` file in an editor of your choice. Configure the following keys:
125143

126144
```bash
127145
sudo vi /etc/krb5.conf
146+
```
128147

148+
```output
129149
[libdefaults]
130-
default_realm = DOMAIN.COMPANY.COM
131-
150+
default_realm = DOMAIN.CONTOSO.COM
151+
132152
[realms]
133-
DOMAIN.COMPANY.COM = {
134-
kdc = dc-33.domain.company.com
153+
DOMAIN.CONTOSO.COM = {
154+
kdc = dc-33.domain.contoso.com
135155
}
136156
```
137157

138-
Then save the krb5.conf file and exit.
158+
Then save the `krb5.conf` file and exit.
139159

140-
> [!NOTE]
160+
> [!NOTE]
141161
> The domain must be in ALL CAPS.
142162
163+
---
143164

144165
## Test the ticket granting ticket retrieval
145166

146167
Get a Ticket Granting Ticket (TGT) from KDC.
147168

148169
```bash
149-
kinit username@DOMAIN.COMPANY.COM
170+
kinit username@DOMAIN.CONTOSO.COM
150171
```
151172

152-
View the available tickets by using klist. If the kinit was successful, you should see a ticket.
173+
View the available tickets by using `klist`. If the `kinit` was successful, you should see a ticket.
153174

154175
```bash
155176
klist
177+
```
156178

157-
krbtgt/DOMAIN.COMPANY.COM@ DOMAIN.COMPANY.COM.
179+
Here's the expected output:
180+
181+
```output
182+
krbtgt/DOMAIN.CONTOSO.COM@ DOMAIN.CONTOSO.COM.
158183
```
159184

160185
## Connect by using Azure Data Studio
161186

162187
1. Create a new connection profile.
163188

164-
1. Enter for Server hostname.DOMAIN.COMPANY.COM and select **Windows Authentication** as the authentication type.
189+
1. Select **Windows Authentication** as the authentication type.
190+
191+
1. For the Server, enter a fully qualified host name, in the format `hostname.DOMAIN.CONTOSO.COM`.
165192

166193
1. Complete the connection profile, and select **Connect**.
167194

0 commit comments

Comments
 (0)