Skip to content

Instantly share code, notes, and snippets.

@nzbart
Last active May 1, 2020 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nzbart/9018aac0004f11127af01fe61b0e4884 to your computer and use it in GitHub Desktop.
Save nzbart/9018aac0004f11127af01fe61b0e4884 to your computer and use it in GitHub Desktop.
Join a Debian/Ubuntu based server to a Windows domain so that users can ssh with domain credentials
# Replace example.com with your domain
hostnamectl set-hostname <hostname>.example.com # FQDN required for DNS registrations by realm (not sure why)
mkdir -p /var/log/journal # Persist logs across reboots
apt update && apt full-upgrade -y && apt auto-remove -y # Get software up to date
apt install -y unattended-upgrades packagekit realmd dnsutils sudo # Install required packages
pam-auth-update --enable mkhomedir # Allow automatic creation of home directories for domain users
echo '%domain\ admins@example.com ALL=(ALL:ALL) ALL' > /etc/sudoers.d/example.com # Allow all domain users to act as root in high-trust environments
ssh-keyscan localhost | ssh-keygen -lf - # Take a record of the SSH keys for secure login
realm join -v -U <your unqualified domain user name> example.com # Join domain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment