Skip to content

Conversation

@s4heid
Copy link
Contributor

@s4heid s4heid commented Dec 1, 2025

  • Run first-boot tasks via systemd so sshd never races with host-key regeneration. The old rc.local script ran in parallel with multi-user services, so ssh.service often started (and restarted) while /root/firstboot.sh was deleting keys. cloud-init’s set-passwords module made this worse by restarting ssh mid-run.
  • Replace rc.local with a oneshot firstboot.service (delete keys, create new keys, reconfigure sysstat) that runs Before=ssh.service and leaves the /root/firstboot_done file as a marker - as was done previously.
  • Add a cloud-config.service drop-in so config stage waits for firstboot.service, and
  • Update walinuxagent.service to follow the same unit ordering as upstream v2.14.0.1 (After=network-online.target cloud-init.service) and wait for firstboot.service to ensure ssh keys have been regenerated. This guarantees sshd, cloud-init, and WALinuxAgent all start only after the first-boot tasks succeed.

Resolves #458

 * Run first-boot tasks via systemd so sshd never races with host-key
regeneration. The old `rc.local` script ran after network.target, but in
parallel with other regular system services, like ssh.service. Therefore,
ssh.service often started (and restarted) while `/root/firstboot.sh` was
deleting keys. cloud-init’s set-passwords module made this worse by restarting
ssh mid-run.
 * Replace `rc.local` with a oneshot firstboot.service
(delete keys, create new keys, reconfigure sysstat) that runs
Before=ssh.service and leaves the `/root/firstboot_done` file as a marker - as
was done previously.
 * Add a cloud-config.service drop-in so cloud-init's config stage waits for
firstboot.service, and
 * Update walinuxagent.service to follow the same unit ordering as upstream
`v2.14.0.1` (After=network-online.target cloud-init.service) and wait for
firstboot.service to ensure ssh keys have been regenerated. This guarantees
sshd, cloud-init, and WALinuxAgent all start only after the first-boot tasks
succeed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

ssh.service failures on azure stemcells

1 participant