Joining a Red Hat Enterprise Linux system to Active Directory domain without an interactive password entry

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 9
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 7
  • Microsoft Windows 2003 R2 / 2008 / 2008 R2 / 2012 / 2016 with Active Directory configured
  • Direct integration (AD/SSSD/Winbind)

Issue

  • An Administrator needs to automate system enrollment into the active directory domain using scripts or automation tools, and the password should not be interactively prompted for.

Resolution

Execute the following command on the server intended to join the Active Directory (AD) domain. Please note that you need to substitute and with a valid password and username, respectively.

echo 'user_password' | realm join -U <user_name> example.local

See the examples below with the realm join and net ads commands:

Join RHEL systems to Active Directory using Winbind

[root@rhel79winbind ~]# echo 'mypassword123' | net ads join -U Administrator
Enter Administrator's password:
Using short domain name -- EXAMPLE
Joined 'RHEL79WINBIND' to dns domain 'example.local'

Joining RHEL systems directly to AD using SSSD

[root@rhel9sssd1 ~]# echo mypassword123 | realm join -U Administrator example.local
Password for Administrator: 
[root@rhel9sssd1 ~]# 

NOTE: If the password contains special characters, enclose it in quotes(''). This documentation only covers domain joining. Refer to the documentation for full requirements.

Reference:
- How to join RHEL to Active Directory using realmd - Red Hat Customer Portal
- How do I join RHEL to Active Directory using Winbind? - Red Hat Customer Portal
- Chapter 1. Connecting RHEL systems directly to AD using SSSD Red Hat Enterprise Linux 8 | Red Hat Customer Portal

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments