fix(ec2): let a systemd guest's init start sshd (#6882)

Floci started /usr/sbin/sshd itself in every guest, including systemd ones
whose image starts sshd from its own unit at boot. The two raced for port
22: if Floci's won, ssh.service failed, and the stray daemon outside systemd
kept the port, so a later `systemctl restart ssh` (to apply an
sshd_config change, as user data commonly does) failed too. On EC2 the AMI's
init alone starts sshd; systemd guests now work the same way.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-10-28 21:11:09 -04:00
1 parent 177f8e9360
commit 0e87e6f1de
3 files changed
+13 -2

No files matched your search

@@ -560,7 +560,13 @@ public class Ec2ContainerManager {
// key-pair association) - starting it only when a key was present meant
// run-instances without --key-name produced a "connection refused" instead of AWS's
// actual behavior: a running daemon with simply nothing to authenticate against.
startSshd(containerId, instanceId);
// A systemd guest is the exception: its init starts sshd from the image's own unit,
// as it does on EC2. A second sshd launched here raced that unit for port 22, and
// whichever lost left either the unit failed or a daemon outside systemd that a
// later `systemctl restart ssh` could not replace.
if (!image.systemd()) {
startSshd(containerId, instanceId);
}
// Execute UserData
String userData = instance.getUserData();