Post-quantum SSH quietly became a real option for Ansible users two weeks ago. The AAP 2.7 patch release from 19 October lets the automation controller and execution environments use the hybrid mlkem768x25519-sha256 key exchange when they connect to RHEL 9.8 or later. The interesting part is what you do not have to do: there is no AAP setting to flip. The feature comes from the RHEL system-wide crypto policy, so the whole job is a RHEL change, and RHEL changes across a fleet are exactly what Ansible is for.

This post is the rollout I would run: figure out which hosts can take it, turn it on for one host, check that it actually did something, and then widen the circle. Nothing here is hard. The risk is in doing it everywhere at once and finding out on Monday morning that some odd client no longer connects.

Why bother before quantum computers exist?

The usual argument is “store now, decrypt later”. Someone records encrypted traffic today and waits until it can be broken. The OpenSSH project puts it bluntly: traffic sent today is at risk unless it uses a post-quantum key agreement, which is why OpenSSH 10.1 started warning when a connection does not.

For automation traffic this argument is stronger than for most. Think about what actually travels over the SSH sessions your playbooks open: rendered configuration files, service passwords passed as module arguments, private keys being deployed, database credentials pulled from a vault a second earlier. An Ansible connection is not a random shell session. It is often the most secret-dense traffic in the data center. If any SSH traffic deserves a better key exchange first, it is this.

It also helps to know where the defaults are going. According to Red Hat’s post on post-quantum cryptography in RHEL 10.1, the DEFAULT policy in RHEL 10.1 already enables and prefers post-quantum key exchange for TLS and SSH. On RHEL 9 you opt in. Doing that now on the hosts you automate is less a leap and more catching up with where the platform is heading anyway.

What actually changes

On RHEL 9.7, crypto-policies gained a PQ subpolicy. Running update-crypto-policies --set DEFAULT:PQ adds the hybrid ML-KEM algorithms on top of the DEFAULT policy and gives them the highest priority. The RHEL 9 security hardening guide recommends a reboot afterwards so that running services pick up the new settings. The subpolicy works with LEGACY, FUTURE and FIPS too, not only DEFAULT.

On the AAP side, the PQC overview for AAP 2.7 describes the feature as strictly additive and opt-in, with RSA and ECDSA configurations continuing to work. For SSH there are two version lines that matter:

  • Platform hosts (where AAP itself runs) need RHEL 9.7 or later, and Red Hat’s instructions are to set DEFAULT:PQ on all of them. The enablement procedure is literally that one command plus a check.
  • Managed nodes need RHEL 9.8 or later for supported PQC SSH. The release notes explain why: on 9.7 the policy gives you sntrup761x25519-sha512, on 9.8 and later you get mlkem768x25519-sha256.

So the real work is the managed nodes. That is where the inventory is large, mixed and a little bit surprising.

Step 1: Find out who can take it

Before changing anything I want a list. Which hosts are on 9.8 or newer, which are on RHEL 10.1 and already have it by default, and which have a custom crypto policy that someone set years ago and nobody remembers. That last group is the one that bites.

---
- name: Map post-quantum SSH readiness
  hosts: rhel
  gather_facts: true
  become: true
  tasks:
    - name: Read the active crypto policy
      ansible.builtin.command: update-crypto-policies --show
      register: crypto_policy
      changed_when: false

    - name: Group hosts by readiness
      ansible.builtin.group_by:
        key: >-
          {% if ansible_distribution_major_version == '10'
                and ansible_distribution_version is version('10.1', '>=') %}pq_native
          {%- elif ansible_distribution_major_version == '9'
                and ansible_distribution_version is version('9.8', '>=')
                and crypto_policy.stdout == 'DEFAULT' %}pq_candidate
          {%- else %}pq_review{% endif %}

    - name: Report what we found
      ansible.builtin.debug:
        msg: "RHEL {{ ansible_distribution_version }}, policy {{ crypto_policy.stdout }}"

Three groups come out of this. pq_native is RHEL 10.1 and later: just verify, there is nothing to set. pq_candidate is RHEL 9.8 or later running plain DEFAULT: those are the ones we change. pq_review is everything else: older minors, RHEL 8, RHEL 10.0, and any host already on FIPS, FUTURE or a custom subpolicy. Those need a person to look at them. A FIPS host should become FIPS:PQ, not be flattened to DEFAULT:PQ by an over-eager playbook.

I use the built-in version test rather than comparing strings, because '9.10' > '9.8' is false as a string comparison and that is the kind of bug you only find in two years.

Step 2: Change one host, then a few, then the rest

For the change itself I use the crypto_policies RHEL system role instead of a raw command. It is idempotent, it knows when a reboot is needed, and with crypto_policies_reboot_ok it will do that reboot for you. After the reboot, the playbook reads the effective sshd configuration and refuses to continue if the result is not what we expect.

- name: Enable post-quantum key exchange
  hosts: pq_candidate
  become: true
  serial:
    - 1
    - "10%"
    - "50%"
  max_fail_percentage: 0
  tasks:
    - name: Set DEFAULT:PQ and reboot if needed
      ansible.builtin.include_role:
        name: redhat.rhel_system_roles.crypto_policies
      vars:
        crypto_policies_policy: "DEFAULT:PQ"
        crypto_policies_reboot_ok: true

    - name: Read the effective sshd configuration
      ansible.builtin.command: sshd -T
      register: sshd_effective
      changed_when: false

    - name: Extract the key exchange list
      ansible.builtin.set_fact:
        sshd_kex: >-
          {{ (sshd_effective.stdout_lines
              | select('match', '^kexalgorithms ')
              | first).split(' ')[1].split(',') }}

    - name: ML-KEM offered, classic fallback still there
      ansible.builtin.assert:
        that:
          - "'mlkem768x25519-sha256' in sshd_kex"
          - "'curve25519-sha256' in sshd_kex"
        fail_msg: "Unexpected key exchange list on {{ inventory_hostname }}: {{ sshd_kex }}"

The serial list does the canary work: one host first, then ten percent, then half, then the rest. With max_fail_percentage: 0 a single failed assertion stops the run before the next batch starts. The second assertion matters as much as the first. The point is to add a better option, not to remove the one your older clients still need, and I want the playbook to prove that rather than trust it.

If you run this from AAP, make it a job template with a limit on the first run and a survey for the batch sizes. The person pressing the button should not have to edit YAML to go from one host to ten percent.

Step 3: Check what a real connection negotiates

sshd offering ML-KEM is only half the story. The client has to offer it too, and in AAP the client is the execution environment talking to your host. Two quick checks:

# On the managed node: what does sshd offer, in priority order?
sshd -T | grep ^kexalgorithms

# From a client that supports it (RHEL 9.8+ with DEFAULT:PQ, or RHEL 10.1+):
ssh -v admin@node1.example.com true 2>&1 | grep 'kex: algorithm'

To see what a job actually used, run a small job against a canary host at verbosity 4 (-vvvv). At that level Ansible runs ssh in debug mode and shows its output, and the kex: algorithm line should name mlkem768x25519-sha256. If it still shows a classic algorithm, check the platform hosts first. Both ends have to want it.

Five things that will surprise you if you skip the inventory

  • Not every SSH client in your automation is OpenSSH. The release notes say SSH clients inside collections, such as paramiko and boto3, are not covered in this first phase. Network automation that uses paramiko or libssh keeps negotiating classic key exchange. That is fine, just do not report it as covered.
  • Not every connection in AAP is in scope. The AAP 2.7 overview lists Receptor mesh peer connections, internal Envoy mTLS, AAP on OpenShift and inbound Event-Driven Ansible activations among the things this release does not cover. PQC SSH to managed nodes is one specific path, not a property of the whole platform.
  • The reboot is part of the change. A crypto policy change that has not been followed by a service restart is a policy on disk, not in use. Plan it like any other reboot window. If you are already rebooting this week for the Critical kernel fix in RHSB-2026-016, it is tempting to bundle the two. Just do not hold back the kernel update while you wait for the crypto change to be ready. The kernel fix is the urgent one.
  • Admins will start seeing warnings. Laptops on OpenSSH 10.1 or newer warn when a server does not offer a post-quantum key exchange. Once some of your fleet is PQ-ready, the hosts that are not will stand out. Treat that as a free progress report, not as noise to silence.
  • Certificates are a separate project. The same AAP release lets you use ML-DSA TLS certificates, but you have to supply them yourself, and the release notes list a known issue where ML-DSA certificates on private automation hub break image pushes and pulls. Key exchange first. Signatures and certificates are a later, slower step.

Where this leaves you

This is one of the rare security improvements that is opt-in, additive and cheap. It is a single policy line per host, a reboot you can schedule, and a handful of assertions that prove it worked. The work is not the change itself. It is knowing your fleet well enough to make it safely, and that is the same lesson every automation project ends up teaching: the inventory and the verification are the job, the change is the easy part.

If you only do one thing this week, run the readiness play. Even if you do not enable anything yet, a list of which hosts are on what minor release, with which crypto policy, is worth having before the next advisory lands.

Resources