Skip to content

Instantly share code, notes, and snippets.

@rechner
Created December 18, 2019 02:22
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 rechner/f61dbadc34d853da77bba1bdfc9fe1b3 to your computer and use it in GitHub Desktop.
Save rechner/f61dbadc34d853da77bba1bdfc9fe1b3 to your computer and use it in GitHub Desktop.

Flavoured for a Debian 10 IPA-joined web server, and based on these pages from the FreeIPA wiki:

Install pre-requisites

# Install pre-requisites
sudo apt install libapache2-mod-authnz-pam libapache2-mod-auth-kerb libapache2-mod-auth-gssapi

# libapache2-mod-nss isn't packaged for Buster for some reason, but oldstable package works fine:
wget http://ftp.us.debian.org/debian/pool/main/liba/libapache2-mod-nss/libapache2-mod-nss_1.0.14-1+b1_amd64.deb && \
sudo dpkg -i libapache2-mod-nss_1.0.14-1+b1_amd64.deb

By default, the package creates a new-format (cert9+key4) NSS database, which mod-nss doesn't appear to support. Create an old, berkley-based database:

sudo certutil -N -d dbm:/etc/apache2/ipa_nssdb
# It will prompt for a password to protect the database, which can be blank.

# Set permissions:
sudo chmod 640 /etc/apache2/nssdb/key3.db /etc/apache2/nssdb/cert8.db /etc/apache2/nssdb/secmod.db
sudo chgrp www-data /etc/apache2/nssdb/cert8.db /etc/apache2/nssdb/key3.db /etc/apache2/nssdb/secmod.db

# Activate NSS apache module and restart apache
sudo a2enmod nss
sudo systemctl restart apache2

If apache crashes, you can revert the above changes and check your logs: sudo a2dismod nss && sudo systemctl restart apache2

(B.N.: mod_nss probably isn't actually required here - certmonger can always generate bare certificate files with the -k option, for instance, and mod_ssl should be able to do the rest - but it's what FreeIPA on a RHEL client would do so I'm sticking with that for now)

Create BHAC service and rules

We start out with an allow_all rule, so it's ok to skip this for testing.

# TODO
# See also:
ipa help hbacsvc
ipa help hbacrule
ipa help hbactest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment