This repository contains a set of Ansible playbooks and Bash scripts designed to manage and enforce system-wide cryptographic policies on Linux systems. The primary goal is to apply a sub-policy that effectively disables known weak ciphers and hashing algorithms, such as CBC and HMAC-SHA1, ensuring a stronger security posture.
Modern cryptography is an essential component of a secure system. This project provides both automated (Ansible) and manual (Bash) methods to implement and back out a system-wide crypto sub-policy. This dual-method approach ensures that administrators can enforce critical security settings consistently and reliably, regardless of their preferred workflow.
- Dual-Method Approach: Provides both idempotent Ansible playbooks and self-contained Bash scripts for flexible deployment and management.
- Remediation: Enforces a crypto sub-policy that disables weak ciphers and hashes, a critical step for hardening systems against modern threats.
- Backout Functionality: Includes dedicated backout scripts and playbooks to safely restore the system to its previous state, enabling easy and safe rollbacks.
- Automated Backups: Both methods create backups of the
krb5.conffile before making any changes.
crypto_subPolicy.yml: An Ansible playbook to apply the crypto sub-policy. It removes weak Kerberos settings, creates the necessary.pmodfiles, and sets the new system-wide policy.crypto_subPolicy_BACKOUT.yml: An Ansible playbook to revert the changes. It restores the backed-upkrb5.conffile and resets the crypto policy toDEFAULT.crypto_subPolicy.sh: A Bash script that performs the same remediation actions as the Ansible playbook. This is ideal for manual, one-off deployments.crypto_subPolicy_BACKOUT.sh: A Bash script to revert the changes made by the main Bash script.
- Ansible: Automation engine for managing configurations.
- Bash: Shell scripting language for manual execution.
- YAML: For defining Ansible playbooks.
- Linux: Specifically targeting systems using
update-crypto-policies.
Note: Always review the code and test in a non-production environment before applying it to critical systems.
- Place the
crypto_subPolicy.ymlandcrypto_subPolicy_BACKOUT.ymlplaybooks in your Ansible environment. - Run the remediation playbook:
ansible-playbook -i <your_inventory_file> crypto_subPolicy.yml
- To back out the changes, run the backout playbook:
ansible-playbook -i <your_inventory_file> crypto_subPolicy_BACKOUT.yml
- Copy the
crypto_subPolicy.shandcrypto_subPolicy_BACKOUT.shscripts to the target system. - Make the scripts executable:
chmod +x crypto_subPolicy.sh crypto_subPolicy_BACKOUT.sh
- Run the remediation script with
sudoor as the root user:sudo ./crypto_subPolicy.sh
- To back out the changes, run the backout script with
sudo:sudo ./crypto_subPolicy_BACKOUT.sh