Skip to content

Commit e253b22

Browse files
authored
Merge pull request #86421 from iainfoulds/azureadds-linux-domain-join
[AzureADDS] Linux domain-join updates
2 parents ca386b4 + 4e73028 commit e253b22

File tree

4 files changed

+513
-340
lines changed

4 files changed

+513
-340
lines changed
Lines changed: 126 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,201 @@
11
---
2-
title: 'Azure Active Directory Domain Services: Join a CentOS VM to a managed domain | Microsoft Docs'
3-
description: Join a CentOS Linux virtual machine to Azure AD Domain Services
2+
title: Join a CentOS VM to Azure AD Domain Services | Microsoft Docs'
3+
description: Learn how to configure and join a CentOS Linux virtual machine to an Azure AD Domain Services managed domain.
44
services: active-directory-ds
5-
documentationcenter: ''
65
author: iainfoulds
76
manager: daveba
8-
editor: curtand
97

108
ms.assetid: 16100caa-f209-4cb0-86d3-9e218aeb51c6
119
ms.service: active-directory
1210
ms.subservice: domain-services
1311
ms.workload: identity
14-
ms.tgt_pltfrm: na
15-
ms.devlang: na
1612
ms.topic: conceptual
17-
ms.date: 05/20/2019
13+
ms.date: 09/15/2019
1814
ms.author: iainfou
1915

2016
---
21-
# Join a CentOS Linux virtual machine to a managed domain
22-
This article shows you how to join a CentOS Linux virtual machine in Azure to an Azure AD Domain Services managed domain.
17+
# Join a CentOS Linux virtual machine to an Azure AD Domain Services managed domain
2318

24-
[!INCLUDE [active-directory-ds-prerequisites.md](../../includes/active-directory-ds-prerequisites.md)]
19+
To let users sign in to virtual machines (VMs) in Azure using a single set of credentials, you can join VMs to an Azure Active Directory Domain Services (AD DS) managed domain. When you join a VM to an Azure AD DS managed domain, user accounts and credentials from the domain can be used to sign in and manage servers. Group memberships from the Azure AD DS managed domain are also applied to let you control access to files or services on the VM.
2520

26-
## Before you begin
27-
To perform the tasks listed in this article, you need:
28-
1. A valid **Azure subscription**.
29-
2. An **Azure AD directory** - either synchronized with an on-premises directory or a cloud-only directory.
30-
3. **Azure AD Domain Services** must be enabled for the Azure AD directory. If you haven't done so, follow all the tasks outlined in the [Getting Started guide](tutorial-create-instance.md).
31-
4. Ensure that you have configured the IP addresses of the managed domain as the DNS servers for the virtual network. For more information, see [how to update DNS settings for the Azure virtual network](tutorial-create-instance.md#update-dns-settings-for-the-azure-virtual-network)
32-
5. Complete the steps required to [synchronize passwords to your Azure AD Domain Services managed domain](tutorial-create-instance.md#enable-user-accounts-for-azure-ad-ds).
21+
This article shows you how to join a CentOS Linux VM to an Azure AD DS managed domain.
3322

23+
## Prerequisites
24+
25+
To complete this tutorial, you need the following resources and privileges:
26+
27+
* An active Azure subscription.
28+
* If you don’t have an Azure subscription, [create an account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
29+
* An Azure Active Directory tenant associated with your subscription, either synchronized with an on-premises directory or a cloud-only directory.
30+
* If needed, [create an Azure Active Directory tenant][create-azure-ad-tenant] or [associate an Azure subscription with your account][associate-azure-ad-tenant].
31+
* An Azure Active Directory Domain Services managed domain enabled and configured in your Azure AD tenant.
32+
* If needed, the first tutorial [creates and configures an Azure Active Directory Domain Services instance][create-azure-ad-ds-instance].
33+
* A user account that's a member of the *Azure AD DC administrators* group in your Azure AD tenant.
34+
35+
## Create and connect to a CentOS Linux VM
36+
37+
If you have an existing CentOS Linux VM in Azure, connect to it using SSH, then continue on to the next step to [start configuring the VM](#configure-the-hosts-file).
38+
39+
If you need to create a CentOS Linux VM, or want to create a test VM for use with this article, you can use one of the following methods:
3440

35-
## Provision a CentOS Linux virtual machine
36-
Provision a CentOS virtual machine in Azure, using any of the following methods:
3741
* [Azure portal](../virtual-machines/linux/quick-create-portal.md)
3842
* [Azure CLI](../virtual-machines/linux/quick-create-cli.md)
3943
* [Azure PowerShell](../virtual-machines/linux/quick-create-powershell.md)
4044

41-
> [!IMPORTANT]
42-
> * Deploy the virtual machine into the **same virtual network in which you have enabled Azure AD Domain Services**.
43-
> * Pick a **different subnet** than the one in which you have enabled Azure AD Domain Services.
44-
>
45-
45+
When you create the VM, pay attention to the virtual network settings to make sure that the VM can communicate with the Azure AD DS managed domain:
4646

47-
## Connect remotely to the newly provisioned Linux virtual machine
48-
The CentOS virtual machine has been provisioned in Azure. The next task is to connect remotely to the virtual machine using the local administrator account created while provisioning the VM.
47+
* Deploy the VM into the same, or a peered, virtual network in which you have enabled Azure AD Domain Services.
48+
* Deploy the VM into a different subnet than your Azure AD Domain Services instance.
4949

50-
Follow the instructions in the article [How to sign in to a virtual machine running Linux](../virtual-machines/linux/mac-create-ssh-keys.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
50+
Once the VM is deployed, follow the steps to connect to the VM using SSH.
5151

52+
## Configure the hosts file
5253

53-
## Configure the hosts file on the Linux virtual machine
54-
In your SSH terminal, edit the /etc/hosts file and update your machine’s IP address and hostname.
54+
To make sure that the VM host name is correctly configured for the managed domain, edit the */etc/hosts* file and set the hostname:
5555

5656
```console
5757
sudo vi /etc/hosts
5858
```
5959

60-
In the hosts file, enter the following value:
60+
In the *hosts* file, update the *localhost* address. In the following example:
61+
62+
* *contoso.com* is the DNS domain name of your Azure AD DS managed domain.
63+
* *centos* is the hostname of your CentOS VM that you're joining to the managed domain.
64+
65+
Update these names with your own values:
6166

6267
```console
63-
127.0.0.1 contoso-centos.contoso.com contoso-centos
68+
127.0.0.1 centos centos.contoso.com
6469
```
6570

66-
Here, 'contoso.com' is the DNS domain name of your managed domain. 'contoso-centos' is the hostname of the CentOS virtual machine you are joining to the managed domain.
71+
When done, save and exit the *hosts* file using the `:wq` command of the editor.
6772

73+
## Install required packages
6874

69-
## Install required packages on the Linux virtual machine
70-
Next, install packages required for domain join on the virtual machine. In your SSH terminal, type the following command to install the required packages:
75+
The VM needs some additional packages to join the VM to the Azure AD DS managed domain. To install and configure these packages, update and install the domain-join tools using `yum`:
7176

7277
```console
7378
sudo yum install realmd sssd krb5-workstation krb5-libs oddjob oddjob-mkhomedir samba-common-tools
7479
```
7580

81+
## Join VM to the managed domain
7682

77-
## Join the Linux virtual machine to the managed domain
78-
Now that the required packages are installed on the Linux virtual machine, the next task is to join the virtual machine to the managed domain.
83+
Now that the required packages are installed on the VM, join the VM to the Azure AD DS managed domain.
7984

80-
1. Discover the AAD Domain Services managed domain. In your SSH terminal, type the following command:
85+
1. Use the `realm discover` command to discover the Azure AD DS managed domain. The following example discovers the realm *CONTOSO.COM*. Specify your own Azure AD DS managed domain name in ALL UPPERCASE:
8186

8287
```console
8388
sudo realm discover CONTOSO.COM
8489
```
8590

86-
> [!NOTE]
87-
> **Troubleshooting:**
88-
> If *realm discover* is unable to find your managed domain:
89-
> * Ensure that the domain is reachable from the virtual machine (try ping).
90-
> * Check that the virtual machine has indeed been deployed to the same virtual network in which the managed domain is available.
91-
> * Check to see if you have updated the DNS server settings for the virtual network to point to the domain controllers of the managed domain.
91+
If the `realm discover` command can't find your Azure AD DS managed domain, review the following troubleshooting steps:
92+
93+
* Make sure that the domain is reachable from the VM. Try `ping contoso.com` to see if a positive reply is returned.
94+
* Check that the VM is deployed to the same, or a peered, virtual network in which the Azure AD DS managed domain is available.
95+
* Confirm that the DNS server settings for the virtual network have been updated to point to the domain controllers of the Azure AD DS managed domain.
96+
97+
1. Now initialize Kerberos using the `kinit` command. Specify a user that belongs to the *AAD DC Administrators* group. If needed, [add a user account to a group in Azure AD](../active-directory/fundamentals/active-directory-groups-members-azure-portal.md).
98+
99+
Again, the Azure AD DS managed domain name must be entered in ALL UPPERCASE. In the following example, the account named `[email protected]` is used to initialize Kerberos. Enter your own user account that's a member of the *AAD DC Administrators* group:
100+
101+
```console
102+
103+
```
104+
105+
1. Finally, join the machine to the Azure AD DS managed domain using the `realm join` command. Use the same user account that's a member of the *AAD DC Administrators* group that you specified in the previous `kinit` command, such as `[email protected]`:
106+
107+
```console
108+
sudo realm join --verbose CONTOSO.COM -U '[email protected]'
109+
```
110+
111+
It takes a few moments to join the VM to the Azure AD DS managed domain. The following example output shows the VM has successfully joined to the Azure AD DS managed domain:
112+
113+
```output
114+
Successfully enrolled machine in realm
115+
```
116+
117+
If your VM can't successfully complete the domain-join process, make sure that the VM's network security group allows outbound Kerberos traffic on TCP + UDP port 464 to the virtual network subnet for your Azure AD DS managed domain.
118+
119+
## Allow password authentication for SSH
120+
121+
By default, users can only sign in to a VM using SSH public key-based authentication. Password-based authentication fails. When you join the VM to an Azure AD DS managed domain, those domain accounts need to use password-based authentication. Update the SSH configuration to allow password-based authentication as follows.
122+
123+
1. Open the *sshd_conf* file with an editor:
124+
125+
```console
126+
sudo vi /etc/ssh/sshd_config
127+
```
128+
129+
1. Update the line for *PasswordAuthentication* to *yes*:
92130

93-
2. Initialize Kerberos. In your SSH terminal, type the following command:
131+
```console
132+
PasswordAuthentication yes
133+
```
134+
135+
When done, save and exit the *sshd_conf* file using the `:wq` command of the editor.
94136

95-
> [!TIP]
96-
> * Specify a user who belongs to the 'AAD DC Administrators' group. If needed, [add a user account to a group in Azure AD](../active-directory/fundamentals/active-directory-groups-members-azure-portal.md)
97-
> * Specify the domain name in capital letters, else kinit fails.
137+
1. To apply the changes and let users sign in using a password, restart the SSH service:
98138

99139
```console
100-
140+
sudo systemctl restart sshd
101141
```
102142

103-
3. Join the machine to the domain. In your SSH terminal, type the following command:
143+
## Grant the 'AAD DC Administrators' group sudo privileges
104144

105-
> [!TIP]
106-
> Use the same user account you specified in the preceding step ('kinit').
107-
>
108-
> If your VM is unable to join the domain, make sure that the VM's network security group allows outbound Kerberos traffic on TCP + UDP port 464 to the virtual network subnet for your Azure AD DS managed domain.
145+
To grant members of the *AAD DC Administrators* group administrative privileges on the CentOS VM, you add an entry to the */etc/sudoers*. Once added, members of the *AAD DC Administrators* group can use the `sudo` command on the CentOS VM.
146+
147+
1. Open the *sudoers* file for editing:
109148

110149
```console
111-
sudo realm join --verbose CONTOSO.COM -U '[email protected]'
150+
sudo visudo
112151
```
113152

114-
You should get a message ("Successfully enrolled machine in realm") when the machine is successfully joined to the managed domain.
153+
1. Add the following entry to the end of */etc/sudoers* file. The *AAD DC Administrators* group contains whitespace in the name, so include the backslash escape character in the group name. Add your own domain name, such as *contoso.com*:
115154

155+
```console
156+
# Add 'AAD DC Administrators' group members as admins.
157+
%AAD\ DC\ [email protected] ALL=(ALL) NOPASSWD:ALL
158+
```
116159

117-
## Verify domain join
118-
Verify whether the machine has been successfully joined to the managed domain. Connect to the domain joined CentOS VM using a different SSH connection. Use a domain user account and then check to see if the user account is resolved correctly.
160+
When done, save and exit the editor using the `:wq` command of the editor.
161+
162+
## Sign in to the VM using a domain account
163+
164+
To verify that the VM has been successfully joined to the Azure AD DS managed domain, start a new SSH connection using a domain user account. Confirm that a home directory has been created, and that group membership from the domain is applied.
165+
166+
1. Create a new SSH connection from your console. Use a domain account that belongs to the managed domain using the `ssh -l` command, such as `[email protected]` and then enter the address of your VM, such as *centos.contoso.com*. If you use the Azure Cloud Shell, use the public IP address of the VM rather than the internal DNS name.
119167

120-
1. In your SSH terminal, type the following command to connect to the domain joined CentOS virtual machine using SSH. Use a domain account that belongs to the managed domain (for example, '[email protected]' in this case.)
121-
122168
```console
123-
ssh -l bob@CONTOSO.COM contoso-centos.contoso.com
169+
ssh -l contosoadmin@CONTOSO.com centos.contoso.com
124170
```
125171

126-
2. In your SSH terminal, type the following command to see if the home directory was initialized correctly.
127-
172+
1. When you've successfully connected to the VM, verify that the home directory was initialized correctly:
173+
128174
```console
129175
pwd
130176
```
131177

132-
3. In your SSH terminal, type the following command to see if the group memberships are being resolved correctly.
133-
178+
You should be in the */home* directory with your own directory that matches the user account.
179+
180+
1. Now check that the group memberships are being resolved correctly:
181+
134182
```console
135183
id
136184
```
137185

186+
You should see your group memberships from the Azure AD DS managed domain.
187+
188+
1. If you signed in to the VM as a member of the *AAD DC Administrators* group, check that you can correctly use the `sudo` command:
189+
190+
```console
191+
sudo yum update
192+
```
193+
194+
## Next steps
138195

139-
## Troubleshooting domain join
140-
Refer to the [Troubleshooting domain join](join-windows-vm.md#troubleshoot-domain-join-issues) article.
196+
If you have problems connecting the VM to the Azure AD DS managed domain or signing in with a domain account, see [Troubleshooting domain join issues](join-windows-vm.md#troubleshoot-domain-join-issues).
141197

142-
## Related Content
143-
* [Azure AD Domain Services - Getting Started guide](tutorial-create-instance.md)
144-
* [Join a Windows Server virtual machine to an Azure AD Domain Services managed domain](active-directory-ds-admin-guide-join-windows-vm.md)
145-
* [How to sign in to a virtual machine running Linux](../virtual-machines/linux/mac-create-ssh-keys.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
146-
* [Installing Kerberos](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Managing_Smart_Cards/installing-kerberos.html)
147-
* [Red Hat Enterprise Linux 7 - Windows Integration Guide](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Windows_Integration_Guide/index.html)
198+
<!-- INTERNAL LINKS -->
199+
[create-azure-ad-tenant]: ../active-directory/fundamentals/sign-up-organization.md
200+
[associate-azure-ad-tenant]: ../active-directory/fundamentals/active-directory-how-subscriptions-associated-directory.md
201+
[create-azure-ad-ds-instance]: tutorial-create-instance.md

0 commit comments

Comments
 (0)