
Ansible playbook that upgrades OpenSSH to 10.6p2 on Alpine Linux to remediate CVE-2026-123158
Ansible playbook that upgrades OpenSSH on Alpine Linux to close CVE-2026-123158 ("sshhole"), then runs the detection script again and fails if the host is still exposed.
On musl libc without PAM, sshd accepts any password longer than 256 bytes for
accounts whose shadow field is exactly *. That is not every passwordless
account: busybox adduser -D writes !, and the script only counts *. Check
what your hosts actually have with the detection script before assuming.
The fix landed in OpenSSH 10.6p2, which is in edge while stable is still on
10.0p1.
ansible-core 2.16 or newer on the controller.python3 when missing; set
-e sshole_bootstrap_python=false to manage it yourself.become on the targets.alpine group, see inventory.example.ini.The playbook is a plain ansible-playbook with no roles, no collections and no
interactive prompts, so it runs unchanged under AWX, Red Hat Ansible Automation
Platform and Semaphore UI.
| Platform | Minimum | Notes |
|---|---|---|
| AWX | execution environment with ansible-core 2.16+ | recent awx-ee is fine, verify with ansible --version |
| Ansible Automation Platform | 2.5 or newer (ships ansible-core 2.16) | 2.4 ships 2.14 and fails on meta: end_host |
| Semaphore UI | runner with ansible-core 2.16+ | the official image has lagged before, pin or install it |
alpine group.mode, sshole_sha256 and alpine_reboot as survey or extra variables.become.delegate_to: localhost runs inside the execution environment or runner
container, not on your laptop. Anything written there is ephemeral, so rely
on the job log instead of a file.sshole_script_url and edge_repo for
air-gapped setups.* account names, so it lands in the job
log and may be visible to more people than you expect.mode as a survey variable.alpine group, an environment with
the SSH key, and a task template that passes -e mode=openssh.cp inventory.example.ini inventory.ini # then edit it
ansible-playbook -i inventory.ini sshhole-remediate.yml -e mode=openssh
mode=openssh (default) upgrades only the installed openssh* packages from
edge. It appends one line to /etc/apk/repositories:
@edge https://dl-cdn.alpinelinux.org/alpine/edge/main
That tag pins the openssh packages to edge. In apk, a tagged package passes the
tag to its dependencies, so a dependency that the untagged repositories cannot
satisfy can also come from edge. On Alpine 3.22 in practice only the six
openssh* packages move, because the stable libraries satisfy them. Only
edge/main is added; a dependency that lives in edge/community would make
the upgrade fail loudly.
Without the pin the next apk upgrade --available pulls the stable version back
and silently reopens the hole. The pin lives in /etc/apk/world once apk add
runs, so it survives reboots and later upgrades.
mode=full rewrites every uncommented repository line to edge, refreshes the
index and runs apk upgrade --available. This is a one way upgrade: there is no
supported downgrade path back to stable, only a reinstall. A previous @edge
line and the world entry are left in place; they are redundant once every repo
points to edge, but harmless.
/etc/apk/repositories: the @edge line, or every line in full mode./etc/apk/world: the openssh packages become pinned to @edge.ssh-keygen -A runs after the upgrade. OpenSSH 10.6 adds an
ML-DSA host key type, and a restart without the key in place fails the key
exchange while sshd -t still returns 0.sshd is restarted, not reloaded. After an in-place upgrade a SIGHUP makes
it re-exec the deleted old binary through /proc/self/exe, so new
connections break. A restart keeps established sessions, only the listener
is replaced. The play then checks that the listener process runs the
upgraded binary, and fails if it does not./etc/ssh/sshd_config is never touched. The playbook does not lock accounts or
disable password authentication.
A second run with no package changes reports ok and does not restart sshd,
unless the listener is still running an older binary, in which case it is
restarted and reported as changed.
full mode keeps a copy before touching anything:
cp -a /etc/apk/repositories.pre-edge /etc/apk/repositories
openssh mode is not undone by restoring the repositories file alone. apk add openssh@edge records openssh@edge in /etc/apk/world, so dropping the only
@edge repository definition leaves a world constraint with nowhere to resolve
from. The order matters:
@edge suffix from the openssh entries in /etc/apk/world.@edge line from /etc/apk/repositories.apk update.apk does not downgrade on its
own, so the version has to be pinned, for example
apk add --upgrade 'openssh=10.0_p1-r11'.Test the downgrade on a canary before relying on it.
The playbook does not vendor the script. It downloads it at run time from oz9un/sshole, the upstream repository:
https://raw.githubusercontent.com/oz9un/sshole/main/check.sh
It is fetched on the controller, never on the targets, and executed as root on every target.
0: exposed1: not exposed2: can't tellA 2 produces a warning, not a failure. Any other exit code fails the play.
The default tracks main. Pin it when you want to be sure of what you are
executing:
ansible-playbook -i inventory.ini sshhole-remediate.yml \
-e mode=openssh \
-e sshole_sha256=<sha256 of check.sh>
--check runs the target validation, the package inventory, and the exposure
check on the targets, simulates the repository edits, and skips the package
upgrade and the post-check. It is a partial preview, not a full simulation.