Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/mysql_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ jobs:
fail-fast: false
matrix:
molecule_distro:
- almalinux8
- almalinux9
# - almalinux10 # problem with baseline
- centosstream9
- rocky8
- rocky9
# - rocky10 # problem with baseline
- ubuntu2004
- ubuntu2204
- ubuntu2404
- debian11
- debian12
- debian13
# - amazon # geerlingguy.mysql does not support fedora
# - arch # geerlingguy.mysql does not support arch
- opensuse_tumbleweed
Expand All @@ -71,7 +76,7 @@ jobs:
pip install "ansible-core<2.17"
ansible-galaxy collection install 'community.crypto:<3.0.0'
working-directory: ansible_collections/devsec/hardening
if: matrix.molecule_distro == 'rocky8'
if: matrix.molecule_distro == 'rocky8' || matrix.molecule_distro == 'almalinux8'

# that was a hard one to fix. robert did it thankfully
# https://github.com/robertdebock/ansible-role-mysql/commit/7562e99099b06282391ab7ed102b393a0406d212
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/nginx_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,19 @@ jobs:
fail-fast: false
matrix:
molecule_distro:
- almalinux8
- almalinux9
- almalinux10
- centosstream9
- rocky8
- rocky9
- rocky10
- ubuntu2004
- ubuntu2204
- ubuntu2404
- debian11
- debian12
- debian13
- amazon2023
# - arch # needs to be fixed
# - opensuse_tumbleweed # needs to be fixed
Expand All @@ -70,7 +75,7 @@ jobs:
pip install "ansible-core<2.17"
ansible-galaxy collection install 'community.crypto:<3.0.0'
working-directory: ansible_collections/devsec/hardening
if: matrix.molecule_distro == 'rocky8'
if: matrix.molecule_distro == 'rocky8' || matrix.molecule_distro == 'almalinux8'

# Molecule has problems detecting the proper location for installing roles
# https://github.com/ansible/molecule/issues/3806
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/os_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,21 @@ jobs:
- molecule_distro: opensuse_tumbleweed
molecule_docker_command: "/usr/lib/systemd/systemd"
molecule_distro:
- almalinux8
- almalinux9
- almalinux10
- centosstream9
- rocky8
- rocky9
- rocky10
- fedora39
- fedora40
- ubuntu2004
- ubuntu2204
- ubuntu2404
- debian11
- debian12
- debian13
- amazon2023
- arch
molecule_docker_command:
Expand All @@ -75,7 +80,7 @@ jobs:
pip install "ansible-core<2.17"
ansible-galaxy collection install 'community.crypto:<3.0.0'
working-directory: ansible_collections/devsec/hardening
if: matrix.molecule_distro == 'rocky8'
if: matrix.molecule_distro == 'rocky8' || matrix.molecule_distro == 'almalinux8'

- name: Test with molecule
run: molecule test -s os_hardening
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/os_hardening_vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
fail-fast: false
matrix:
molecule_distro:
- almalinux/8
- almalinux/9
# - almalinux/10 # boot loop
- generic/centos9s
- generic/rocky8
- generic/rocky9
Expand Down Expand Up @@ -69,7 +72,10 @@ jobs:
pip install "ansible-core<2.17"
ansible-galaxy collection install 'community.crypto:<3.0.0'
working-directory: ansible_collections/devsec/hardening
if: matrix.molecule_distro == 'generic/rocky8' || matrix.molecule_distro == 'generic/opensuse15'
if: >
matrix.molecule_distro == 'generic/rocky8' ||
matrix.molecule_distro == 'almalinux/8' ||
matrix.molecule_distro == 'generic/opensuse15'

- name: Update Vagrant Box
run: |
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ssh_hardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,21 @@ jobs:
- molecule_distro: alpine
molecule_docker_command: "/sbin/init"
molecule_distro:
- almalinux8
- almalinux9
- almalinux10
- centosstream9
- rocky8
- rocky9
- rocky10
- fedora39
- fedora40
- ubuntu2004
- ubuntu2204
- ubuntu2404
- debian11
- debian12
- debian13
- amazon2023
- arch
molecule_docker_command:
Expand All @@ -78,7 +83,7 @@ jobs:
pip install "ansible-core<2.17"
ansible-galaxy collection install 'community.crypto:<3.0.0'
working-directory: ansible_collections/devsec/hardening
if: matrix.molecule_distro == 'rocky8'
if: matrix.molecule_distro == 'rocky8' || matrix.molecule_distro == 'almalinux8'

- name: Test with molecule
run: molecule test -s ssh_hardening
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ssh_hardening_custom_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,21 @@ jobs:
- molecule_distro: alpine
molecule_docker_command: "/sbin/init"
molecule_distro:
- almalinux8
- almalinux9
- almalinux10
- centosstream9
- rocky8
- rocky9
- rocky10
- fedora39
- fedora40
- ubuntu2004
- ubuntu2204
- ubuntu2404
- debian11
- debian12
- debian13
- amazon2023
- arch
molecule_docker_command:
Expand All @@ -78,7 +83,7 @@ jobs:
pip install "ansible-core<2.17"
ansible-galaxy collection install 'community.crypto:<3.0.0'
working-directory: ansible_collections/devsec/hardening
if: matrix.molecule_distro == 'rocky8'
if: matrix.molecule_distro == 'rocky8' || matrix.molecule_distro == 'almalinux8'

- name: Test with molecule
run: molecule test -s ssh_hardening_custom_tests
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ This collection provides battle tested hardening for:

- Linux operating systems:
- CentOS Stream 9
- AlmaLinux 8/9
- Rocky Linux 8/9
- Debian 11/12
- AlmaLinux 8/9/10
- Rocky Linux 8/9/10
- Debian 11/12/13
- Ubuntu 20.04/22.04/24.04
- Amazon Linux (some roles supported)
- Arch Linux (some roles supported)
Expand Down
7 changes: 6 additions & 1 deletion molecule/os_hardening_vm/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
- python3-libselinux
when: ansible_facts.distribution == 'Fedora'

- name: Install required tools on AlmaLinux
ansible.builtin.dnf:
name:
- initscripts
when: ansible_facts.distribution == 'AlmaLinux'

- name: Install required tools on Arch
community.general.pacman:
name:
Expand All @@ -84,7 +90,6 @@
ansible.posix.mount:
path: /boot/efi
state: unmounted
when: ansible_facts.distribution == 'Fedora'

- name: Include YUM prepare tasks
ansible.builtin.include_tasks: prepare_tasks/yum.yml
Expand Down
7 changes: 1 addition & 6 deletions molecule/ssh_hardening/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@
update_cache: true
when: ansible_facts.os_family == 'Archlinux'

- name: Create ssh host keys # noqa ignore-errors
- name: Create ssh host keys # noqa ignore-errors no-changed-when
ansible.builtin.command: ssh-keygen -A
when: not ((ansible_facts.os_family in ['Oracle Linux', 'RedHat']) and ansible_facts.distribution_major_version < '7')
or ansible_facts.distribution == "Fedora"
or ansible_facts.distribution == "Amazon"
or ansible_facts.os_family == "Suse"
changed_when: false
ignore_errors: true
7 changes: 1 addition & 6 deletions molecule/ssh_hardening_custom_tests/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@
update_cache: true
when: ansible_facts.os_family == 'Alpine'

- name: Create ssh host keys # noqa ignore-errors
- name: Create ssh host keys # noqa ignore-errors no-changed-when
ansible.builtin.command: ssh-keygen -A
when: not ((ansible_facts.os_family in ['Oracle Linux', 'RedHat']) and ansible_facts.distribution_major_version < '7')
or ansible_facts.distribution == "Fedora"
or ansible_facts.distribution == "Amazon"
or ansible_facts.os_family == "Suse"
changed_when: false
ignore_errors: true
4 changes: 3 additions & 1 deletion roles/mysql_hardening/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ galaxy_info:
versions:
- "8"
- "9"
- "10"
- name: Ubuntu
versions:
- focal
- jammy
- noble
- name: Debian
versions:
- bullseye
- trixie
- bookworm
- bullseye
- name: Amazon
- name: opensuse
galaxy_tags:
Expand Down
2 changes: 2 additions & 0 deletions roles/nginx_hardening/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ galaxy_info:
versions:
- "8"
- "9"
- "10"
- name: Ubuntu
versions:
- focal
- jammy
- noble
- name: Debian
versions:
- trixie
- bookworm
- bullseye
- name: Amazon
Expand Down
2 changes: 2 additions & 0 deletions roles/os_hardening/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ galaxy_info:
versions:
- "8"
- "9"
- "10"
- name: Ubuntu
versions:
- focal
- jammy
- noble
- name: Debian
versions:
- trixie
- bookworm
- bullseye
- name: Amazon
Expand Down
2 changes: 2 additions & 0 deletions roles/ssh_hardening/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ galaxy_info:
versions:
- "8"
- "9"
- "10"
- name: Ubuntu
versions:
- focal
- jammy
- noble
- name: Debian
versions:
- trixie
- bookworm
- bullseye
- name: Alpine
Expand Down
26 changes: 26 additions & 0 deletions roles/ssh_hardening/vars/RedHat_10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
ssh_pkgs:
- openssh
sshd_path: /usr/sbin/sshd
ssh_host_keys_dir: /etc/ssh
sshd_service_name: sshd
ssh_owner: root
ssh_group: root
ssh_host_keys_owner: root
ssh_host_keys_group: root
ssh_host_keys_mode: "0600"
ssh_selinux_packages:
- policycoreutils-python-utils
- checkpolicy

# true if SSH support Kerberos
ssh_kerberos_support: true

# true if SSH has PAM support
ssh_pam_support: true

sshd_moduli_file: /etc/ssh/moduli

# disable CRYPTO_POLICY to take settings from sshd configuration
# see: https://access.redhat.com/solutions/4410591
sshd_disable_crypto_policy: true