Harden authorized_keys role with always-present admin keys - #73
Merged
Conversation
Member
|
Hey @fe51 , one issue with the preflight checks: the run_once: true on the "Check that every referenced public key file exists" and "Fail if any referenced public key file is missing" tasks should be removed. With run_once, the check runs only once, using the key list of the first host of the play. But ssh_authorized_keys is a per-group variable, so the other hosts' keys are never checked. Step by step with make sync-ssh-keys (hosts: all) and the pi-manager-fr#65 inventory:
Fix: just delete the two run_once: true lines. Each host then checks its own list, a missing file fails early with the clear "Public key file not found" message, before anything is written. The cost is only a few extra local stat calls, negligible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pitch
Makes the
authorized_keysrole safe to run withexclusive: true, andextends SSH key syncing to the server hosts.
issue
The role enforces
exclusive: true, which removes any key not in the list.Nothing guaranteed our own access key stayed in that set — an empty or
mistaken
ssh_authorized_keys(or a missing.pub) could silently lock usout of a host.
Aslo The role was also only wired into engine/Pi setup, so
alert_server/platform_react_servernever had their keys enforced atdeploy time.
Changes
ssh_admin_keys(new): trusted admin/backup keys, always appended ontop of
ssh_authorized_keys. Guarantees these keys surviveexclusive: true.Set once in
group_vars/all/vars.yml, so per-host lists only carryuser-specific accesses (no more repeating the trusted team everywhere).
authorized_keys:ssh_admin_keysis empty (lockout guard);.pubis missing on the controller,with a clear message instead of a cryptic
lookuperror.deploy-servers.yml: sync authorized keys onalert_serverandplatform_react_serverduring deploy.