Skip to content

Fix Ubuntu 24.04 SSH hardening #878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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: 4 additions & 3 deletions .config/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ exclude_paths:
- .ansible/ # somehow someone decided that the cache directory should be renamed
# add all waivers individually, since exclude_files does not support globs
- molecule/os_hardening/waivers.yaml
- molecule/ssh_hardening_bsd/waivers_freebsd13.yaml
- molecule/ssh_hardening_bsd/waivers_freebsd14.yaml
- molecule/ssh_hardening_bsd/waivers_openbsd7.yaml
- molecule/ssh_hardening_vm/waivers_freebsd13.yaml
- molecule/ssh_hardening_vm/waivers_freebsd14.yaml
- molecule/ssh_hardening_vm/waivers_openbsd7.yaml
- molecule/ssh_hardening_vm/waivers_ubuntu-24.04.yaml

mock_roles:
- geerlingguy.git
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
name: "devsec.ssh_hardening BSD"
name: "devsec.ssh_hardening VM"
on: # yamllint disable-line rule:truthy
workflow_dispatch:
push:
branches: [master]
paths:
- 'roles/ssh_hardening/**'
- 'molecule/ssh_hardening_bsd/**'
- '.github/workflows/ssh_hardening_bsd.yml'
- 'molecule/ssh_hardening_vm/**'
- '.github/workflows/ssh_hardening_vm.yml'
- 'requirements.txt'
pull_request:
branches: [master]
paths:
- 'roles/ssh_hardening/**'
- 'molecule/ssh_hardening_bsd/**'
- '.github/workflows/ssh_hardening_bsd.yml'
- 'molecule/ssh_hardening_vm/**'
- '.github/workflows/ssh_hardening_vm.yml'
- 'requirements.txt'
schedule:
- cron: '0 6 * * 5'
Expand All @@ -36,21 +36,33 @@ jobs:
fail-fast: false
matrix:
molecule_distro:
- openbsd7
- freebsd13
- freebsd14
- generic/openbsd7
- generic/freebsd13
- generic/freebsd14
- cloud-image/ubuntu-24.04
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
path: ansible_collections/devsec/hardening
submodules: true

- name: Install dependencies
run: |
source ~/.venv/ansible-collection-hardening/bin/activate
python -m pip install --no-cache-dir --upgrade pip
pip install -r requirements.txt
pip install python-vagrant
working-directory: ansible_collections/devsec/hardening

- name: Update Vagrant Box
run: vagrant box update --box generic/${{ matrix.molecule_distro }} || true
run: |
vagrant box update --box ${{ matrix.molecule_distro }} || true

- name: Test with molecule
run: molecule test -s ssh_hardening_bsd
run: |
source ~/.venv/ansible-collection-hardening/bin/activate
molecule test -s ssh_hardening_vm
env:
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
working-directory: ansible_collections/devsec/hardening
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![devsec.os_hardening](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/os_hardening.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/os_hardening.yml)
[![devsec.os_hardening VM](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/os_hardening_vm.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/os_hardening_vm.yml)
[![devsec.ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening.yml)
[![devsec.ssh_hardening BSD](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_bsd.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_bsd.yml)
[![devsec.ssh_hardening VM](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_vm.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_vm.yml)
[![devsec.ssh_hardening with custom tests](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_custom_tests.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_custom_tests.yml)
[![devsec.nginx_hardening](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/nginx_hardening.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/nginx_hardening.yml)
[![devsec.mysql_hardening](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/mysql_hardening.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/mysql_hardening.yml)
Expand Down
17 changes: 11 additions & 6 deletions molecule/ssh_hardening/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,32 @@
ansible_python_interpreter: /usr/bin/python3
when: ansible_facts.distribution == 'Fedora'

- name: Install packages # noqa ignore-errors
- name: Install dnf packages # noqa ignore-errors
ansible.builtin.dnf:
name:
- openssh-clients
- openssh-server
state: present
update_cache: true
ignore_errors: true

- name: Install libselinux-python # noqa ignore-errors
ansible.builtin.dnf:
name:
- libselinux-python
state: present
update_cache: true
ignore_errors: true

- name: Install packages # noqa ignore-errors
- name: Install procps-ng # noqa ignore-errors
ansible.builtin.dnf:
name:
- openssh-clients
- openssh-server
- procps-ng
state: present
update_cache: true
ignore_errors: true

- name: Install packages # noqa ignore-errors
- name: Install apt packages # noqa ignore-errors
ansible.builtin.apt:
name:
- openssh-client
Expand All @@ -47,7 +52,7 @@
changed_when: false
when: ansible_facts.os_family == 'Suse'

- name: Install packages
- name: Install packages on SuSE
community.general.zypper:
name:
- openssh
Expand Down
15 changes: 10 additions & 5 deletions molecule/ssh_hardening_custom_tests/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,32 @@
ansible_python_interpreter: /usr/bin/python3
when: ansible_facts.distribution == 'Fedora'

- name: Install packages # noqa ignore-errors
- name: Install dnf packages # noqa ignore-errors
ansible.builtin.dnf:
name:
- openssh-clients
- openssh-server
state: present
update_cache: true
ignore_errors: true

- name: Install libselinux-python # noqa ignore-errors
ansible.builtin.dnf:
name:
- libselinux-python
state: present
update_cache: true
ignore_errors: true

- name: Install packages # noqa ignore-errors
- name: Install procps-ng # noqa ignore-errors
ansible.builtin.dnf:
name:
- openssh-clients
- openssh-server
- procps-ng
state: present
update_cache: true
ignore_errors: true

- name: Install packages # noqa ignore-errors
- name: Install apt packages # noqa ignore-errors
ansible.builtin.apt:
name:
- openssh-client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ platforms:
# since we also need to use different OS users to run the tests because of how molecule operates,
# the VM names must be predictable by OS user (to clean up canceled runs)
- name: ${USER}
box: generic/${MOLECULE_DISTRO}
box: ${MOLECULE_DISTRO}
memory: 1024
cpus: 2
provisioner:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
ansible.builtin.command: >
docker run --rm
--volume {{ molecule_ephemeral_directory }}:{{ molecule_ephemeral_directory }}
--volume ./waivers_{{ lookup('env', 'MOLECULE_DISTRO') }}.yaml:/waivers.yaml
--volume ./waivers_{{ lookup('env', 'MOLECULE_DISTRO') | regex_replace('^.*/', '') }}.yaml:/waivers.yaml
docker.io/cincproject/auditor exec
--ssh-config-file={{ molecule_ephemeral_directory }}/ssh-config
-t ssh://{{ lookup('env', 'USER') }}
Expand Down
2 changes: 2 additions & 0 deletions molecule/ssh_hardening_vm/waivers_ubuntu-24.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
{}
2 changes: 1 addition & 1 deletion roles/ssh_hardening/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# dev-sec.ssh_hardening

[![devsec.ssh_hardening](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening.yml)
[![devsec.ssh_hardening BSD](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_bsd.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_bsd.yml)
[![devsec.ssh_hardening VM](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_vm.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_vm.yml)
[![devsec.ssh_hardening with custom tests](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_custom_tests.yml/badge.svg)](https://github.com/dev-sec/ansible-collection-hardening/actions/workflows/ssh_hardening_custom_tests.yml)

## Description
Expand Down
Loading