Join a Red Hat Enterprise Linux virtual machine to a Microsoft Entra Domain Services managed domain
Статия
To let users sign in to virtual machines (VMs) in Azure using a single set of credentials, you can join VMs to a Microsoft Entra Domain Services managed domain. When you join a VM to a Domain Services managed domain, user accounts and credentials from the domain can be used to sign in and manage servers. Group memberships from the managed domain are also applied to let you control access to files or services on the VM.
This article shows you how to join a Red Hat Enterprise Linux (RHEL) VM to a managed domain.
Prerequisites
To complete this tutorial, you need the following resources and privileges:
Keep in consideration Red Hat Enterprise Linux 6.X and Oracle Linux 6.x is already EOL.
RHEL 6.10 has available ELS support, which ended on 06/2024.
Install required packages
The VM needs some additional packages to join the VM to the managed domain. To install and configure these packages, update and install the domain-join tools using yum.
Now that the required packages are installed on the VM, join the VM to the managed domain.
Use the adcli info command to discover the managed domain. The following example discovers the realm ADDDSCONTOSO.COM. Specify your own managed domain name in ALL UPPERCASE:
Bash
sudo adcli info aaddscontoso.com
If the adcli info command can't find your managed domain, review the following troubleshooting steps:
Make sure that the domain is reachable from the VM. Try ping aaddscontoso.com to see if a positive reply is returned.
Check that the VM is deployed to the same, or a peered, virtual network in which the managed domain is available.
Confirm that the DNS server settings for the virtual network are updated to point to the domain controllers of the managed domain.
First, join the domain using the adcli join command. This command also creates the keytab to authenticate the machine. Use a user account that's a part of the managed domain.
Bash
sudo adcli join aaddscontoso.com -U contosoadmin
Now configure the /ect/krb5.conf and create the /etc/sssd/sssd.conf files to use the aaddscontoso.com Active Directory domain.
Make sure that AADDSCONTOSO.COM is replaced by your own domain name:
Open the /etc/krb5.conf file with an editor:
Bash
sudo vi /etc/krb5.conf
Update the krb5.conf file to match the following sample:
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 managed domain.
Now check if you can query user AD information using getent
Bash
sudo getent passwd contosoadmin
Allow password authentication for SSH
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 a managed domain, those domain accounts need to use password-based authentication. Update the SSH configuration to allow password-based authentication as follows.
Open the sshd_conf file with an editor:
Bash
sudo vi /etc/ssh/sshd_config
Update the line for PasswordAuthentication to yes:
config
PasswordAuthentication yes
When done, save and exit the sshd_conf file using the :wq command of the editor.
To apply the changes and let users sign in using a password, restart the SSH service for your RHEL distro version:
Bash
sudo service sshd restart
Install required packages
The VM needs some additional packages to join the VM to the managed domain. To install and configure these packages, update and install the domain-join tools using yum.
Now that the required packages are installed on the VM, join the VM to the managed domain. Again, use the appropriate steps for your RHEL distro version.
Use the realm discover command to discover the managed domain. The following example discovers the realm AADDSCONTOSO.COM. Specify your own managed domain name in ALL UPPERCASE:
Bash
sudo realm discover AADDSCONTOSO.COM
If the realm discover command can't find your managed domain, review the following troubleshooting steps:
Make sure that the domain is reachable from the VM. Try ping aaddscontoso.com to see if a positive reply is returned.
Check that the VM is deployed to the same, or a peered, virtual network in which the managed domain is available.
Confirm that the DNS server settings for the virtual network are updated to point to the domain controllers of the managed domain.
Again, the managed domain name must be entered in ALL UPPERCASE. In the following example, the account named contosoadmin@aaddscontoso.com is used to initialize Kerberos. Enter your own user account that's a part of the managed domain:
Bash
sudo kinit contosoadmin@AADDSCONTOSO.COM
Finally, join the VM to the managed domain using the realm join command. Use the same user account that's a part of the managed domain that you specified in the previous kinit command, such as contosoadmin@AADDSCONTOSO.COM:
It takes a few moments to join the VM to the managed domain. The following example output shows the VM successfully joined to the managed domain:
Output
Successfully enrolled machine in realm
Allow password authentication for SSH
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 a managed domain, those domain accounts need to use password-based authentication. Update the SSH configuration to allow password-based authentication as follows.
Open the sshd_conf file with an editor:
Bash
sudo vi /etc/ssh/sshd_config
Update the line for PasswordAuthentication to yes:
Bash
PasswordAuthentication yes
When done, save and exit the sshd_conf file using the :wq command of the editor.
To apply the changes and let users sign in using a password, restart the SSH service.
Bash
sudo systemctl restart sshd
Grant the 'AAD DC Administrators' group sudo privileges
To grant members of the AAD DC Administrators group administrative privileges on the RHEL 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 RHEL VM.
Open the sudoers file for editing:
Bash
sudo visudo
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 aaddscontoso.com:
config
# Add 'AAD DC Administrators' group members as admins.
%AAD\ DC\ Administrators@aaddscontoso.com ALL=(ALL) NOPASSWD:ALL
When done, save and exit the editor using the :wq command of the editor.
Sign in to the VM using a domain account
To verify that the VM successfully joined to the managed domain, start a new SSH connection using a domain user account. Confirm that a home directory is created, and that group membership from the domain is applied.
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 contosoadmin@aaddscontoso.com and then enter the address of your VM, such as rhel.aaddscontoso.com. If you use the Azure Cloud Shell, use the public IP address of the VM rather than the internal DNS name.
This module introduces the management of users and groups using Active Directory, and compares the differences between Active Directory Services and Microsoft Entra ID.