Skip to content

Commit 07cc4cc

Browse files
rndmh3romillerthegorilla
authored andcommitted
feat(ssh): add alpine support (dev-sec#809)
Signed-off-by: Sebastian Gumprich <[email protected]> Signed-off-by: James Miller <[email protected]>
1 parent 38086bc commit 07cc4cc

File tree

7 files changed

+60
-9
lines changed

7 files changed

+60
-9
lines changed

.github/workflows/ssh_hardening.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ jobs:
3535
strategy:
3636
fail-fast: false
3737
matrix:
38+
include:
39+
# needs fix - opensuse has different file location for conf and pam (/usr/etc/ssh/?, /usr/lib/pam.d/?)
40+
# - molecule_distro: opensuse_tumbleweed
41+
# molecule_docker_command: "/usr/lib/systemd/systemd"
42+
- molecule_distro: alpine
43+
molecule_docker_command: "/sbin/init"
44+
molecule_docker_command:
45+
- "/lib/systemd/systemd"
3846
molecule_distro:
3947
- centosstream9
4048
- rocky8
@@ -48,7 +56,6 @@ jobs:
4856
- debian12
4957
- amazon2023
5058
- arch
51-
# - opensuse_tumbleweed # needs fix - opensuse has different file location for conf and pam (/usr/etc/ssh/?, /usr/lib/pam.d/?)
5259
steps:
5360
- name: Checkout repo
5461
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
@@ -76,11 +83,9 @@ jobs:
7683

7784
- name: Test with molecule
7885
run: |
79-
if [ "$MOLECULE_DISTRO" = "opensuse_tumbleweed" ]; then
80-
export MOLECULE_DOCKER_COMMAND="/usr/lib/systemd/systemd"
81-
fi
8286
molecule --version
8387
molecule test -s ssh_hardening
8488
env:
8589
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
90+
MOLECULE_DOCKER_COMMAND: ${{ matrix.molecule_docker_command }}
8691
working-directory: ansible_collections/devsec/hardening

.github/workflows/ssh_hardening_custom_tests.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ jobs:
3535
strategy:
3636
fail-fast: false
3737
matrix:
38+
include:
39+
# needs fix - opensuse has different file location for conf and pam (/usr/etc/ssh/?, /usr/lib/pam.d/?)
40+
# - molecule_distro: opensuse_tumbleweed
41+
# molecule_docker_command: "/usr/lib/systemd/systemd"
42+
- molecule_distro: alpine
43+
molecule_docker_command: "/sbin/init"
44+
molecule_docker_command:
45+
- "/lib/systemd/systemd"
3846
molecule_distro:
3947
- centosstream9
4048
- rocky8
@@ -48,7 +56,6 @@ jobs:
4856
- debian12
4957
- amazon2023
5058
- arch
51-
# - opensuse_tumbleweed # needs fix - opensuse has different file location for conf and pam (/usr/etc/ssh/?, /usr/lib/pam.d/?)
5259
steps:
5360
- name: Checkout repo
5461
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
@@ -76,11 +83,9 @@ jobs:
7683

7784
- name: Test with molecule
7885
run: |
79-
if [ "$MOLECULE_DISTRO" = "opensuse_tumbleweed" ]; then
80-
export MOLECULE_DOCKER_COMMAND="/usr/lib/systemd/systemd"
81-
fi
8286
molecule --version
8387
molecule test -s ssh_hardening_custom_tests
8488
env:
8589
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
90+
MOLECULE_DOCKER_COMMAND: ${{ matrix.molecule_docker_command }}
8691
working-directory: ansible_collections/devsec/hardening

molecule/ssh_hardening/prepare.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Wrapper playbook for kitchen testing "ansible-ssh-hardening" with default settings
2+
- name: Prepare the molecule container for the role
33
hosts: all
44
become: true
55
environment:
@@ -53,6 +53,14 @@
5353
- openssh
5454
when: ansible_facts.os_family == 'Suse'
5555

56+
- name: Install required tools on Alpine
57+
community.general.apk:
58+
name:
59+
- openssh
60+
state: present
61+
update_cache: true
62+
when: ansible_facts.os_family == 'Alpine'
63+
5664
- name: Install required tools on Arch
5765
community.general.pacman:
5866
name:

molecule/ssh_hardening_custom_tests/prepare.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@
6262
update_cache: true
6363
when: ansible_facts.os_family == 'Archlinux'
6464

65+
- name: Install required tools on Alpine
66+
community.general.apk:
67+
name:
68+
- openssh
69+
state: present
70+
update_cache: true
71+
when: ansible_facts.os_family == 'Alpine'
72+
6573
- name: Create ssh host keys # noqa ignore-errors
6674
ansible.builtin.command: ssh-keygen -A
6775
when: not ((ansible_facts.os_family in ['Oracle Linux', 'RedHat']) and ansible_facts.distribution_major_version < '7')

roles/ssh_hardening/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ For more information, see [this issue](https://github.com/dev-sec/ansible-collec
5252
- focal, jammy, noble
5353
- Debian
5454
- bookworm, bullseye
55+
- Alpine
5556
- Amazon
5657
- Fedora
5758
- ArchLinux

roles/ssh_hardening/meta/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ galaxy_info:
1919
versions:
2020
- bookworm
2121
- bullseye
22+
- name: Alpine
2223
- name: Amazon
2324
- name: Fedora
2425
- name: ArchLinux

roles/ssh_hardening/vars/Alpine.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
ssh_pkgs:
3+
- openssh
4+
sshd_path: /usr/sbin/sshd
5+
ssh_host_keys_dir: /etc/ssh
6+
sshd_service_name: sshd
7+
ssh_owner: root
8+
ssh_group: root
9+
ssh_host_keys_owner: root
10+
ssh_host_keys_group: root
11+
ssh_host_keys_mode: "0600"
12+
13+
# true if SSH support Kerberos
14+
ssh_kerberos_support: true
15+
16+
# true if SSH has PAM support
17+
ssh_pam_support: true
18+
19+
sshd_moduli_file: /etc/ssh/moduli
20+
21+
# CRYPTO_POLICY is not supported on Archlinux
22+
# and the package check only works in Ansible >2.10
23+
sshd_disable_crypto_policy: false

0 commit comments

Comments
 (0)