Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
adds option to opt-out of RHEL 8 crypto policies
Browse files Browse the repository at this point in the history
In RHEL 8 these are hard-wired in the service via:

```
EnvironmentFile=-/etc/crypto-policies/back-ends/opensshserver.config
EnvironmentFile=-/etc/sysconfig/sshd
```

The `sysconfig` file can override the ones from crypto policies.
  • Loading branch information
wookietreiber committed Jan 30, 2024
1 parent b2dc23a commit 3a0e7ac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Table of Contents
* [Known Hosts](#known-hosts)
* [Authorized Keys and User Management](#authorized-keys-and-user-management)
* [Moduli](#moduli)
* [Distro Specifics](#distro-specifics)
- [Dependencies](#dependencies)
- [Example Playbook](#example-playbook)
* [Top-Level Playbook](#top-level-playbook)
Expand Down Expand Up @@ -165,6 +166,16 @@ To configure the minimum modulus for `/etc/ssh/moduli`:
ssh_modulus_min: 3071
```

### Distro Specifics

Opt out of distro-specific crypto policies (at the time of writing applies only
to RHEL 8 and derivatives):

```yml
ssh_opt_out_crypto_policies: no
```


Dependencies
------------

Expand Down
1 change: 1 addition & 0 deletions molecule/alternative/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ provisioner:
- [email protected]
ssh_modulus_min: 3071
redhat:
ssh_opt_out_crypto_policies: yes
ssh_subsystems:
- name: sftp
command: '/usr/libexec/openssh/sftp-server -f AUTHPRIV -l INFO'
Expand Down
10 changes: 10 additions & 0 deletions tasks/configuration-sshd.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
---

- name: opt out of crypto policies
ansible.builtin.lineinfile:
path: /etc/sysconfig/sshd
regexp: CRYPTO_POLICY=
line: CRYPTO_POLICY=
become: yes
when:
- ssh_opt_out_crypto_policies | default(False)
- __ssh_os_version == 'redhat_8'

This comment has been minimized.

Copy link
@DirectorSloan

DirectorSloan Feb 12, 2024

can IMHO be for redhat_9 as well as of e.g. [email protected] is still default there as of version 8.7-34 on Rocky 9.3 (latest 12th February 24).

This comment has been minimized.

Copy link
@wookietreiber

wookietreiber Feb 13, 2024

Author Member

I chose to only do this for RHEL 8, because in RHEL 9 crypto-policies is integrated via /etc/ssh/sshd_config.d/50-redhat.conf, and you can override every setting of this file by defining the variables of this role whose values are put into /etc/ssh/sshd_config.d/10-ansible.conf, i.e. these have preference over 50-redhat.conf.


- name: configure sshd in /etc/ssh/sshd_config
ansible.builtin.template:
src: '{{ lookup("first_found", __ssh_sshd_config_templates) }}'
Expand Down

0 comments on commit 3a0e7ac

Please sign in to comment.