KB450253 – Join an Active Directory in Houston UI with Ubuntu 22.04
Last updated October 21, 2026
Joining an Ubuntu 22.04 Server to Active Directory (Houston)
Scope/Description
This article shows how to join an Ubuntu 22.04 server running the 45Drives Houston UI to an Active Directory domain using the current production script ubuntu-domainjoin.sh.
Prerequisites
- Ubuntu 22.04 server with the 45Drives repository configured and Houston UI installed (https://SERVER-IP:9090)
- Network reachability from the server to the domain controller on ports 88 (Kerberos), 389 (LDAP), 3268 (Global Catalog), and 445 (SMB)
- DNS that can resolve the domain (the domain controller itself, or resolvers that forward the domain). The server must be able to resolve the LDAP SRV records for the realm.
- An Active Directory account with permission to join computers to the domain
- The realm name of the domain (for example
45drives.local) and the hostname you want the server to take (the script will set it tohostname.realm)
Verify network and DNS before joining
From the server:
# for p in 88 389 3268 445; do timeout 3 bash -c "echo > /dev/tcp/DC-IP/$p" 2>/dev/null && echo "$p open" || echo "$p BLOCKED"; done
# nslookup -type=SRV _ldap._tcp.DOMAIN.LOCAL
All four ports must report open and the SRV query must return the domain controller. If any port is blocked or the SRV record does not resolve, the join will fail; open the path or fix DNS first.
Steps
Back up the files the script rewrites
The script backs up /etc/samba/smb.conf by itself, but it rewrites /etc/krb5.conf and /etc/nsswitch.conf without backups. Make those first:
# cp /etc/krb5.conf /etc/krb5.conf.bak
# cp /etc/nsswitch.conf /etc/nsswitch.conf.bak
Download the join script
# curl -sSL https://scripts.45drives.com/ubuntu-domainjoin.sh -o /root/ubuntu-domainjoin.sh
# cat /root/ubuntu-domainjoin.sh
Confirm the downloaded file matches the script you expect before running it.
Run the join
# bash /root/ubuntu-domainjoin.sh --hostname SERVERNAME --user ADUSER --realm DOMAIN.LOCAL
The script installs realmd, samba, and krb5-user, sets the hostname to SERVERNAME.DOMAIN.LOCAL, generates a Kerberos ticket, and joins the domain. It prints progress as it runs and prompts for the AD user password at the Kerberos ticket step; realm join may ask for it a second time:
Username: ADUSER
Realm: DOMAIN.LOCAL
Installing prerequisite packages: realmd, samba, krb5-user...
Setting hostname to: SERVERNAME.DOMAIN.LOCAL
Backing up existing samba conf to /etc/samba/smb.conf.<timestamp>.bak
Generating kerberos ticket, please enter password at the prompt...
Password for ADUSER@DOMAIN.LOCAL:
Validating we can discover the domain...
Joining the domain...


The script finishes by enabling smbd and adding include = registry to /etc/samba/smb.conf, so SMB shares can later be managed from the registry via the Houston UI.
Verification
Confirm the domain membership
# realm list
Expected output:
domain.local
domain type: active directory
domain realm: DOMAIN.LOCAL
domain role: none
enumerated users:
ADUSER
client software: winbind
client configuring: active directory
server software: active-directory
resolution: built-in
management server: DC.DOMAIN.LOCAL
login server: DC.DOMAIN.LOCAL

Confirm domain users resolve locally
# wbinfo -t
# id DOMAIN\\ADUSER
# getent passwd | grep DOMAIN | head
wbinfo -t should report "user lookup OK" and id should return the domain account's uid/gid.

Log in to the Houston UI with a domain account
Open https://SERVER-IP:9090/ and sign in as DOMAIN\\user. The login page accepts domain accounts once winbind is running.


Troubleshooting
- All AD ports blocked from the server (88, 389, 3268, 445 closed or filtered): a Windows firewall rule on the DC or a firewall between subnets is blocking the server's IP. Open the ports for the server's IP and re-run the pre-flight check above.
realm discoverfails / SRV records not found: the server's DNS cannot resolve the domain. Point the server's nameserver at the domain controller or add the domain to the existing resolvers, then retry.- kinit password rejected: verify the AD account name and realm spelling (the realm is case-insensitive in the argument but must match the actual DNS domain), and that the account has machine-join rights.
- Join starts then fails mid-way: the script has no automatic rollback. Unjoin and restore as described below, then fix the cause and retry.
Undo (unjoin)
The script performs no rollback. To reverse a join:
# realm leave --user=ADUSER
# hostnamectl set-hostname ORIGINAL-HOSTNAME
# mv /etc/samba/smb.conf.<timestamp>.bak /etc/samba/smb.conf
# cp /etc/krb5.conf.bak /etc/krb5.conf
# cp /etc/nsswitch.conf.bak /etc/nsswitch.conf
# systemctl disable --now smbd
Reboot after restoring the hostname if it does not take effect immediately.