|
1 | 1 | ---
|
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. |
4 | 4 | services: active-directory-ds
|
5 |
| -documentationcenter: '' |
6 | 5 | author: iainfoulds
|
7 | 6 | manager: daveba
|
8 |
| -editor: curtand |
9 | 7 |
|
10 | 8 | ms.assetid: 16100caa-f209-4cb0-86d3-9e218aeb51c6
|
11 | 9 | ms.service: active-directory
|
12 | 10 | ms.subservice: domain-services
|
13 | 11 | ms.workload: identity
|
14 |
| -ms.tgt_pltfrm: na |
15 |
| -ms.devlang: na |
16 | 12 | ms.topic: conceptual
|
17 |
| -ms.date: 05/20/2019 |
| 13 | +ms.date: 09/15/2019 |
18 | 14 | ms.author: iainfou
|
19 | 15 |
|
20 | 16 | ---
|
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 |
23 | 18 |
|
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. |
25 | 20 |
|
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. |
33 | 22 |
|
| 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: |
34 | 40 |
|
35 |
| -## Provision a CentOS Linux virtual machine |
36 |
| -Provision a CentOS virtual machine in Azure, using any of the following methods: |
37 | 41 | * [Azure portal](../virtual-machines/linux/quick-create-portal.md)
|
38 | 42 | * [Azure CLI](../virtual-machines/linux/quick-create-cli.md)
|
39 | 43 | * [Azure PowerShell](../virtual-machines/linux/quick-create-powershell.md)
|
40 | 44 |
|
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: |
46 | 46 |
|
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. |
49 | 49 |
|
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. |
51 | 51 |
|
| 52 | +## Configure the hosts file |
52 | 53 |
|
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: |
55 | 55 |
|
56 | 56 | ```console
|
57 | 57 | sudo vi /etc/hosts
|
58 | 58 | ```
|
59 | 59 |
|
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: |
61 | 66 |
|
62 | 67 | ```console
|
63 |
| -127.0.0.1 contoso-centos.contoso.com contoso-centos |
| 68 | +127.0.0.1 centos centos.contoso.com |
64 | 69 | ```
|
65 | 70 |
|
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. |
67 | 72 |
|
| 73 | +## Install required packages |
68 | 74 |
|
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`: |
71 | 76 |
|
72 | 77 | ```console
|
73 | 78 | sudo yum install realmd sssd krb5-workstation krb5-libs oddjob oddjob-mkhomedir samba-common-tools
|
74 | 79 | ```
|
75 | 80 |
|
| 81 | +## Join VM to the managed domain |
76 | 82 |
|
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. |
79 | 84 |
|
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: |
81 | 86 |
|
82 | 87 | ```console
|
83 | 88 | sudo realm discover CONTOSO.COM
|
84 | 89 | ```
|
85 | 90 |
|
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*: |
92 | 130 |
|
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. |
94 | 136 |
|
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: |
98 | 138 |
|
99 | 139 | ```console
|
100 |
| - |
| 140 | + sudo systemctl restart sshd |
101 | 141 | ```
|
102 | 142 |
|
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 |
104 | 144 |
|
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: |
109 | 148 |
|
110 | 149 | ```console
|
111 |
| - sudo realm join --verbose CONTOSO.COM -U '[email protected]' |
| 150 | + sudo visudo |
112 | 151 | ```
|
113 | 152 |
|
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*: |
115 | 154 |
|
| 155 | + ```console |
| 156 | + # Add 'AAD DC Administrators' group members as admins. |
| 157 | + %AAD\ DC\ [email protected] ALL=(ALL) NOPASSWD:ALL |
| 158 | + ``` |
116 | 159 |
|
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. |
119 | 167 |
|
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 |
| - |
122 | 168 | ```console
|
123 |
| - ssh -l bob@CONTOSO.COM contoso-centos.contoso.com |
| 169 | + ssh -l contosoadmin@CONTOSO.com centos.contoso.com |
124 | 170 | ```
|
125 | 171 |
|
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 | + |
128 | 174 | ```console
|
129 | 175 | pwd
|
130 | 176 | ```
|
131 | 177 |
|
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 | + |
134 | 182 | ```console
|
135 | 183 | id
|
136 | 184 | ```
|
137 | 185 |
|
| 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 |
138 | 195 |
|
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). |
141 | 197 |
|
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