--- # CIS 5.3.x / 5.4.x: Passwortqualitaet, Account-Lockout und Ablaufregeln fuer # LOKALE OS-Konten auf dem Jumphost selbst (Admin-SSH-Zugang zum Jumphost- # Server, siehe ssh_admin_access_cidr in group_vars/all.yml). # # WICHTIG -- Abgrenzung: Dies ist NICHT identisch mit der Argon2id/TOTP- # Pflicht der Jumphost-WEBANWENDUNG (siehe app/security/passwords.py, # app/security/totp.py, app/auth/routes.py). Es handelt sich um zwei # getrennte Konten-/Auth-Systeme: die App verwaltet ihre eigenen Nutzer in # SQLite, waehrend hier die BS-Konten der Administratoren gehaertet werden, # die sich per SSH auf den Jumphost-Server selbst einloggen (z.B. fuer # Wartung, Deployment, Log-Einsicht). - name: libpam-pwquality installieren ansible.builtin.apt: name: libpam-pwquality state: present update_cache: true - name: Passwortqualitaets-Policy setzen (CIS 5.4.1) # Direkt in pwquality.conf statt eines conf.d-Snippets, da nicht jede # Distributionsversion von libpam-pwquality ein conf.d-Verzeichnis # unterstuetzt -- pwquality.conf selbst wird ueberall gelesen. ansible.builtin.lineinfile: path: /etc/security/pwquality.conf regexp: "^#?\\s*{{ item.key }}\\s*=" line: "{{ item.key }} = {{ item.value }}" create: true owner: root group: root mode: "0644" loop: - { key: "minlen", value: "{{ os_hardening_password_min_length }}" } - { key: "dcredit", value: "-1" } - { key: "ucredit", value: "-1" } - { key: "ocredit", value: "-1" } - { key: "lcredit", value: "-1" } - { key: "retry", value: "3" } # Kein Service-Neustart noetig: PAM liest die Datei bei jeder neuen # Authentifizierung, kein laufender Daemon haelt sie offen. - name: Passwortqualitaet auch fuer root erzwingen ansible.builtin.lineinfile: path: /etc/security/pwquality.conf regexp: "^#?\\s*enforce_for_root" line: "enforce_for_root" create: true - name: pam_faillock fuer Login-Lockout aktivieren (CIS 5.3.1) ansible.builtin.blockinfile: path: /etc/pam.d/common-auth marker: "# {mark} ANSIBLE MANAGED BLOCK (jumphost pam_faillock)" insertbefore: "^auth\\s+\\[success=1" block: | auth required pam_faillock.so preauth silent deny={{ os_hardening_faillock_deny }} unlock_time={{ os_hardening_faillock_unlock_time }} auth [success=1 default=ignore] pam_unix.so nullok auth [default=die] pam_faillock.so authfail deny={{ os_hardening_faillock_deny }} unlock_time={{ os_hardening_faillock_unlock_time }} auth sufficient pam_faillock.so authsucc deny={{ os_hardening_faillock_deny }} unlock_time={{ os_hardening_faillock_unlock_time }} # Hinweis: pam-auth-update-verwaltete Systeme (Debian/Ubuntu-Standard) # ueberschreiben common-auth ggf. bei "pam-auth-update --force". Fuer # produktive Systeme ist die Nutzung eines eigenen pam-auth-update-Profils # (/usr/share/pam-configs/jumphost-faillock) die sauberere, upgrade-feste # Alternative -- hier aus Uebersichtlichkeitsgruenden als direkter Block- # Insert gehalten und im Mapping-Dokument als bekannte Einschraenkung vermerkt. - name: Passwort-Ablaufregeln in /etc/login.defs setzen (CIS 5.4.1.1-5.4.1.4) ansible.builtin.lineinfile: path: /etc/login.defs regexp: "^{{ item.key }}\\s" line: "{{ item.key }} {{ item.value }}" loop: - { key: "PASS_MAX_DAYS", value: "90" } - { key: "PASS_MIN_DAYS", value: "7" } - { key: "PASS_WARN_AGE", value: "14" } - { key: "UMASK", value: "027" } - { key: "ENCRYPT_METHOD", value: "SHA512" } - name: Passwort-Historie (pam_pwhistory) aktivieren (CIS 5.4.2) ansible.builtin.lineinfile: path: /etc/pam.d/common-password regexp: '^password\s+requisite\s+pam_pwhistory\.so' insertafter: '^password\s+requisite\s+pam_pwquality\.so' line: "password requisite pam_pwhistory.so remember={{ os_hardening_password_remember }} use_authtok"