Skip to content

Commit 9155b1b

Browse files
committed
formatting edit pass
1 parent 0090b1a commit 9155b1b

File tree

1 file changed

+112
-48
lines changed

1 file changed

+112
-48
lines changed

articles/storage/files/storage-files-identity-auth-linux-kerberos-enable.md

Lines changed: 112 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to enable identity-based Kerberos authentication for Linu
44
author: khdownie
55
ms.service: storage
66
ms.topic: how-to
7-
ms.date: 03/30/2023
7+
ms.date: 04/13/2023
88
ms.author: kendownie
99
ms.subservice: files
1010
---
@@ -43,20 +43,24 @@ Before you enable AD authentication over SMB for Azure file shares, make sure yo
4343
Installing the samba package isn't strictly necessary, but it gives you some useful tools and brings in other packages automatically, such as `samba-common` and `smbclient`. Run the following commands to install it. If you're asked for any input values during installation, leave them blank.
4444

4545
```bash
46-
localadmin@contosovm:~$ sudo apt update -y
47-
localadmin@contosovm:~$ sudo apt install samba winbind libpam-winbind libnss-winbind krb5-config krb5-user keyutils cifs-utils
46+
sudo apt update -y
47+
sudo apt install samba winbind libpam-winbind libnss-winbind krb5-config krb5-user keyutils cifs-utils
4848
```
4949

5050
The `wbinfo` tool is part of the samba suite. It can be useful for authentication and debugging purposes, such as checking if the domain controller is reachable, checking what domain a machine is joined to, and finding information about users.
5151

52-
Make sure that the Linux host keeps the time synchronized with the domain server. Refer to the documentation for your Linux distribution. For some distros, you can do this [using systemd-timesyncd](https://www.freedesktop.org/software/systemd/man/timesyncd.conf.html). Here's a sample configuration.
52+
Make sure that the Linux host keeps the time synchronized with the domain server. Refer to the documentation for your Linux distribution. For some distros, you can do this [using systemd-timesyncd](https://www.freedesktop.org/software/systemd/man/timesyncd.conf.html). Edit `/etc/systemd/timesyncd.conf` with your favorite text editor to include the following:
5353

54-
```bash
55-
localadmin@contosovm:~$ cat /etc/systemd/timesyncd.conf
54+
```plaintext
5655
[Time]
5756
NTP=onpremaadint.com
5857
FallbackNTP=ntp.ubuntu.com
59-
localadmin@contosovm:~$ sudo systemctl restart systemd-timesyncd.service
58+
```
59+
60+
Then restart the service:
61+
62+
```bash
63+
sudo systemctl restart systemd-timesyncd.service
6064
```
6165

6266
## Enable AD Kerberos authentication
@@ -68,8 +72,10 @@ Follow these steps to enable AD Kerberos authentication. [This Samba documentati
6872
1. Make sure that the DNS servers supplied contain the domain server IP addresses.
6973

7074
```bash
71-
localadmin@contosovm:~$ systemd-resolve --status
75+
systemd-resolve --status
76+
```
7277

78+
```output
7379
Global
7480
DNSSEC NTA: 10.in-addr.arpa
7581
16.172.in-addr.arpa
@@ -116,7 +122,10 @@ MulticastDNS setting: no
116122
3. If it didn't work, make sure that the domain server IP addresses are pinging.
117123

118124
```bash
119-
localadmin@contosovm:~$ ping 10.0.2.5
125+
ping 10.0.2.5
126+
```
127+
128+
```output
120129
PING 10.0.2.5 (10.0.2.5) 56(84) bytes of data.
121130
64 bytes from 10.0.2.5: icmp_seq=1 ttl=128 time=0.898 ms
122131
64 bytes from 10.0.2.5: icmp_seq=2 ttl=128 time=0.946 ms
@@ -130,10 +139,9 @@ rtt min/avg/max/mdev = 0.898/0.922/0.946/0.024 ms
130139

131140
4. If the ping doesn't work, go back to [prerequisites](#prerequisites), and make sure that your VM is on a VNET that has access to the Azure AD tenant.
132141

133-
5. If the IP addresses are pinging but the DNS servers aren't automatically discovered, you can add the DNS servers manually.
142+
5. If the IP addresses are pinging but the DNS servers aren't automatically discovered, you can add the DNS servers manually. Edit `/etc/netplan/50-cloud-init.yaml` with your favorite text editor.
134143

135-
```bash
136-
localadmin@contosovm:~$ cat /etc/netplan/50-cloud-init.yaml
144+
```plaintext
137145
# This file is generated from information provided by the datasource. Changes
138146
# to it will not persist across an instance reboot. To disable cloud-init's
139147
# network configuration capabilities, write a file
@@ -152,13 +160,17 @@ network:
152160
nameservers:
153161
addresses: [10.0.2.5, 10.0.2.4]
154162
version: 2
155-
localadmin@contosovm:~$ sudo netplan --debug apply
156163
```
157164

158-
6. Winbind assumes that the DHCP server keeps the domain DNS records up-to-date. However, this isn't true for Azure DHCP. In order to set up the client to make DDNS updates, use [this guide](../../virtual-network/virtual-networks-name-resolution-ddns.md#linux-clients) to create a network script. Here's a sample script.
165+
Then apply the changes:
159166

160167
```bash
161-
localadmin@contosovm:~$ cat /etc/dhcp/dhclient-exit-hooks.d/ddns-update
168+
sudo netplan --debug apply
169+
```
170+
171+
6. Winbind assumes that the DHCP server keeps the domain DNS records up-to-date. However, this isn't true for Azure DHCP. In order to set up the client to make DDNS updates, use [this guide](../../virtual-network/virtual-networks-name-resolution-ddns.md#linux-clients) to create a network script. Here's a sample script that lives at `/etc/dhcp/dhclient-exit-hooks.d/ddns-update`.
172+
173+
```plaintext
162174
#!/bin/sh
163175
164176
# only execute on the primary nic
@@ -186,7 +198,10 @@ fi
186198
1. Make sure that you're able to ping the domain server by the domain name.
187199

188200
```bash
189-
localadmin@contosovm:~$ ping contosodomain.contoso.com
201+
ping contosodomain.contoso.com
202+
```
203+
204+
```output
190205
PING contosodomain.contoso.com (10.0.2.4) 56(84) bytes of data.
191206
64 bytes from pwe-oqarc11l568.internal.cloudapp.net (10.0.2.4): icmp_seq=1 ttl=128 time=1.41 ms
192207
64 bytes from pwe-oqarc11l568.internal.cloudapp.net (10.0.2.4): icmp_seq=2 ttl=128 time=1.02 ms
@@ -203,9 +218,12 @@ rtt min/avg/max/mdev = 0.740/1.026/1.419/0.248 ms
203218
2. Make sure you can discover the Azure AD services on the network.
204219

205220
```bash
206-
localadmin@contosovm:~$ nslookup
221+
nslookup
207222
> set type=SRV
208223
> _ldap._tcp.contosodomain.contoso.com.
224+
```
225+
226+
```output
209227
Server: 127.0.0.53
210228
Address: 127.0.0.53#53
211229
@@ -217,9 +235,9 @@ _ldap._tcp.contosodomain.contoso.com service = 0 100 389 hxt4yo--jb9q529.contoso
217235

218236
### Set up hostname and fully qualified domain name (FQDN)
219237

220-
1. Update the `/etc/hosts` file with the final FQDN (after joining the domain) and the alias for the host. The IP address doesn't matter for now because this line will mainly be used to translate short hostname to FQDN. For more details, see [Setting up Samba as a Domain Member](https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Domain_Member).
238+
1. Using your text editor, update the `/etc/hosts` file with the final FQDN (after joining the domain) and the alias for the host. The IP address doesn't matter for now because this line will mainly be used to translate short hostname to FQDN. For more details, see [Setting up Samba as a Domain Member](https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Domain_Member).
221239

222-
```bash
240+
```plaintext
223241
127.0.0.1 contosovm.contosodomain.contoso.com contosovm
224242
#cmd=sudo vim /etc/hosts
225243
#then enter this value instead of localhost "ubuntvm.contosodomain.contoso.com UbuntuVM"
@@ -228,11 +246,26 @@ _ldap._tcp.contosodomain.contoso.com service = 0 100 389 hxt4yo--jb9q529.contoso
228246
2. Now, your hostname should resolve. You can ignore the IP address it resolves to for now. The short hostname should resolve to the FQDN.
229247

230248
```bash
231-
localadmin@contosovm:~$ getent hosts contosovm
249+
getent hosts contosovm
250+
```
251+
252+
```output
232253
127.0.0.1 contosovm.contosodomain.contoso.com contosovm
233-
localadmin@contosovm:~$ dnsdomainname
254+
```
255+
256+
```bash
257+
dnsdomainname
258+
```
259+
260+
```output
234261
contosodomain.contoso.com
235-
localadmin@contosovm:~$ hostname -f
262+
```
263+
264+
```bash
265+
hostname -f
266+
```
267+
268+
```output
236269
contosovm.contosodomain.contoso.com
237270
```
238271

@@ -243,12 +276,9 @@ contosovm.contosodomain.contoso.com
243276
244277
### Set up krb5.conf
245278

246-
1. Configure `krb5.conf` so that the Kerberos key distribution center (KDC) with the domain server can be contacted for authentication. For more information, see [MIT Kerberos Documentation](https://web.mit.edu/kerberos/krb5-1.12/doc/admin/conf_files/krb5_conf.html). Here's a sample `krb5.conf` file.
279+
1. Configure `/etc/krb5.conf` so that the Kerberos key distribution center (KDC) with the domain server can be contacted for authentication. For more information, see [MIT Kerberos Documentation](https://web.mit.edu/kerberos/krb5-1.12/doc/admin/conf_files/krb5_conf.html). Here's a sample `/etc/krb5.conf` file.
247280

248-
```bash
249-
#sudo vim /etc/krb5.conf
250-
251-
localadmin@contosovm:~$ cat /etc/krb5.conf
281+
```plaintext
252282
[libdefaults]
253283
default_realm = CONTOSODOMAIN.CONTOSO.COM
254284
dns_lookup_realm = false
@@ -260,7 +290,10 @@ localadmin@contosovm:~$ cat /etc/krb5.conf
260290
1. Identify the path to `smb.conf`.
261291

262292
```bash
263-
localadmin@contosovm:~$ sudo smbd -b | grep "CONFIGFILE"
293+
sudo smbd -b | grep "CONFIGFILE"
294+
```
295+
296+
```output
264297
CONFIGFILE: /etc/samba/smb.conf
265298
```
266299

@@ -269,8 +302,7 @@ localadmin@contosovm:~$ sudo smbd -b | grep "CONFIGFILE"
269302
> [!Note]
270303
> This example is for Azure AD DS, for which we recommend setting `backend = rid` when configuring idmap. On-premises AD DS users might prefer to [choose a different idmap backend](https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Domain_Member#Choosing_an_idmap_backend).
271304
272-
```bash
273-
localadmin@contosovm:~$ cat /etc/samba/smb.conf
305+
```plaintext
274306
[global]
275307
workgroup = CONTOSODOMAIN
276308
security = ADS
@@ -307,25 +339,31 @@ localadmin@contosovm:~$ cat /etc/samba/smb.conf
307339
3. Force winbind to reload the changed config file.
308340

309341
```bash
310-
localadmin@contosovm:~$ sudo smbcontrol all reload-config
342+
sudo smbcontrol all reload-config
311343
```
312344

313345
### Join the domain
314346

315347
1. Use the `net ads join` command to join the host to the Azure AD DS domain. If the command throws an error, see [Troubleshooting samba domain members](https://wiki.samba.org/index.php/Troubleshooting_Samba_Domain_Members) to resolve the issue.
316348

317349
```bash
318-
localadmin@contosovm:~$ sudo net ads join -U contososmbadmin # user - garead
350+
sudo net ads join -U contososmbadmin # user - garead
319351

320352
Enter contososmbadmin's password:
353+
```
354+
355+
```output
321356
Using short domain name -- CONTOSODOMAIN
322357
Joined 'CONTOSOVM' to dns domain 'contosodomain.contoso.com'
323358
```
324359
325360
2. Make sure that the DNS record exists for this host on the domain server.
326361
327362
```bash
328-
localadmin@contosovm:~$ nslookup contosovm.contosodomain.contoso.com 10.0.2.5
363+
nslookup contosovm.contosodomain.contoso.com 10.0.2.5
364+
```
365+
366+
```output
329367
Server: 10.0.2.5
330368
Address: 10.0.2.5#53
331369
@@ -337,21 +375,32 @@ If users will be actively logging into client machines or VMs and accessing the
337375
338376
### Set up nsswitch.conf
339377
340-
1. Now that the host is joined to the domain, you need to put winbind libraries in the places to look for when looking for users and groups. Do this by updating the passwd and group entries in `nsswitch.conf`. Run the command `sudo vim /etc/nsswitch.conf` and add the following entries to `nsswitch.conf`:
378+
1. Now that the host is joined to the domain, you need to put winbind libraries in the places to look for when looking for users and groups. Do this by updating the passwd and group entries in `nsswitch.conf`. Use your text editor to edit `/etc/nsswitch.conf` and add the following entries:
341379
342-
```bash
380+
```plaintext
343381
passwd: compat systemd winbind
344382
group: compat systemd winbind
345383
```
346384
347-
2. Enable the winbind service to start automatically on reboot, and then restart the service.
385+
2. Enable the winbind service to start automatically on reboot.
348386
349387
```bash
350-
localadmin@contosovm:~$ sudo systemctl enable winbind
388+
sudo systemctl enable winbind
389+
```
390+
391+
```output
351392
Synchronizing state of winbind.service with SysV service script with /lib/systemd/systemd-sysv-install.
352393
Executing: /lib/systemd/systemd-sysv-install enable winbind
353-
localadmin@contosovm:~$ sudo systemctl restart winbind
354-
localadmin@contosovm:~$ sudo systemctl status winbind
394+
```
395+
396+
3. Then, restart the service.
397+
398+
```bash
399+
sudo systemctl restart winbind
400+
sudo systemctl status winbind
401+
```
402+
403+
```output
355404
winbind.service - Samba Winbind Daemon
356405
Loaded: loaded (/lib/systemd/system/winbind.service; enabled; vendor preset: enabled)
357406
Active: active (running) since Fri 2020-04-24 09:34:31 UTC; 10s ago
@@ -373,42 +422,57 @@ Apr 24 09:34:31 contosovm systemd[1]: Started Samba Winbind Daemon.
373422
Apr 24 09:34:31 contosovm winbindd[27349]: STATUS=daemon 'winbindd' finished starting up and ready to serve connections
374423
```
375424
376-
3. Make sure that the domain users and groups are discovered.
425+
4. Make sure that the domain users and groups are discovered.
377426
378427
```bash
379-
localadmin@contosovm:~$ getent passwd contososmbadmin
428+
getent passwd contososmbadmin
429+
```
430+
431+
```output
380432
contososmbadmin:*:12604:10513::/home/contososmbadmin:/bin/bash
381-
localadmin@contosovm:~$ getent group 'domain users'
433+
```
434+
435+
```bash
436+
getent group 'domain users'
437+
```
438+
439+
```output
382440
domain users:x:10513:
383441
```
384442
385443
If the above doesn't work, check if the domain controller is reachable using the wbinfo tool:
386444

387445
```bash
388-
localadmin@contosovm:~$ wbinfo --ping-dc
446+
wbinfo --ping-dc
389447
```
390448

391449
### Configure PAM for winbind
392450

393451
1. You need to place winbind in the authentication stack so that domain users are authenticated through winbind by configuring PAM (Pluggable Authentication Module) for winbind. The second command ensures that the homedir gets created for a domain user upon first login to this system.
394452

395453
```bash
396-
localadmin@contosovm:~$ sudo pam-auth-update --enable winbind
397-
localadmin@contosovm:~$ sudo pam-auth-update --enable mkhomedir
454+
sudo pam-auth-update --enable winbind
455+
sudo pam-auth-update --enable mkhomedir
398456
```
399457

400458
2. Ensure that the PAM authentication config has the following arguments in `/etc/pam.d/common-auth`:
401459

402460
```bash
403-
localadmin@contosovm:~$ grep pam_winbind.so /etc/pam.d/common-auth
461+
grep pam_winbind.so /etc/pam.d/common-auth
462+
```
463+
464+
```output
404465
auth [success=1 default=ignore] pam_winbind.so krb5_auth krb5_ccache_type=FILE cached_login try_first_pass
405466
```
406467

407468
3. You should now be able to log in to this system as the domain user, either through ssh, su, or any other means of authentication.
408469

409470
```bash
410-
localadmin@contosovm:~$ su - contososmbadmin
471+
su - contososmbadmin
411472
Password:
473+
```
474+
475+
```output
412476
Creating directory '/home/contososmbadmin'.
413477
contososmbadmin@contosovm:~$ pwd
414478
/home/contososmbadmin
@@ -426,7 +490,7 @@ nslookup <clientname> <dnsserver>
426490

427491
Next, use the `klist` command to view the tickets in the Kerberos cache. There should be an entry beginning with `krbtgt` that looks similar to:
428492

429-
```bash
493+
```plaintext
430494
431495
```
432496

0 commit comments

Comments
 (0)