Add Ubuntu to Active Directory

Author: No Comments Share:

To add an Ubuntu 20.04 computer to your Active directory use the following steps

1 Update your system

sudo apt update
sudo apt -y upgrade

2) Add the following repos

sudo tee -a /etc/apt/sources.list <<EOF
deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
EOF

3) Set your hostname (if not already done)

sudo hostnamectl set-hostname myservername.example.com

4) Ubuntu comes with systemd-resolve that needs to be disabled to work with AD DNS servers

sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved

5) Update /etc/resolv.conf

sudo unlink /etc/resolv.conf
sudo nano /etc/resolv.conf

make sure you have the following info in the file

nameserver ww.xx.yy.zz
options edns0 trust-ad
seach example.com

6) Install required packages

sudo apt update
sudo apt -y install realmd libnss-sss libpam-sss sssd sssd-tools adcli samba-common-bin oddjob oddjob-mkhomedir packagekit

7) Discover Active Directory Domain

sudo realm discover example.com

8) Join Active Directory

sudo realm join -U Administrator example.com

confirm domain is active and joined with

realm  list

9) Enable homedir creation

sudo bash -c "cat > /usr/share/pam-configs/mkhomedir" <<EOF
Name: activate mkhomedir
Default: yes
Priority: 900
Session-Type: Additional
Session:
        required                        pam_mkhomedir.so umask=0022 skel=/etc/skel
EOF

and activate the changes

sudo pam-auth-update

make sure to select “activate mkhomedir” option

10) restart sssd service

sudo systemctl restart sssd

11) Allow domain users (Replace group name below if you want to limit logins to a specific group)

sudo realm permit -g 'Domain Users' 'admin users'

12) Configure sudo access (if required)

sudo nano /etc/sudoers.d/domain_admins

and add the following to the file

%domain\ admins@example.com ALL=(ALL:ALL) ALL

13) Test SSH access

ssh DOMAIN\domainuser@localhost

Previous Article

.exe file association in Windows

Next Article

Exchange Calendar Permissions

You may also like