Skip to content

Commit 3c87d4d

Browse files
committed
Add BootstrapSSHKeyPair public key to agent ignition
Add the generated bootstrap SSH public key to the core user's SSHAuthorizedKeys in the agent ignition, alongside the user-provided key from the InfraEnv spec. This enables the installer to SSH to the rendezvous host using the bootstrap key without requiring the user to provide a key. This key does not persist into the cluster, it is only active while the agent ISO is booted. Assisted-by: Claude Code
1 parent 2ba77a4 commit 3c87d4d

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

pkg/asset/agent/image/ignition.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func (a *Ignition) Dependencies() []asset.Asset {
108108
&tls.KubeAPIServerLocalhostSignerCertKey{},
109109
&tls.KubeAPIServerServiceNetworkSignerCertKey{},
110110
&tls.AdminKubeConfigSignerCertKey{},
111+
&tls.BootstrapSSHKeyPair{},
111112
&password.KubeadminPassword{},
112113
&agentconfig.AgentConfig{},
113114
&agentconfig.AgentHosts{},
@@ -136,7 +137,8 @@ func (a *Ignition) Generate(ctx context.Context, dependencies asset.Parents) err
136137
}
137138

138139
pwd := &password.KubeadminPassword{}
139-
dependencies.Get(pwd)
140+
bootstrapSSHKeyPair := &tls.BootstrapSSHKeyPair{}
141+
dependencies.Get(pwd, bootstrapSSHKeyPair)
140142
pwdHash := string(pwd.PasswordHash)
141143

142144
infraEnv := agentManifests.InfraEnv
@@ -151,6 +153,7 @@ func (a *Ignition) Generate(ctx context.Context, dependencies asset.Parents) err
151153
Name: "core",
152154
SSHAuthorizedKeys: []igntypes.SSHAuthorizedKey{
153155
igntypes.SSHAuthorizedKey(infraEnv.Spec.SSHAuthorizedKey),
156+
igntypes.SSHAuthorizedKey(string(bootstrapSSHKeyPair.Public())),
154157
},
155158
PasswordHash: &pwdHash,
156159
},

pkg/asset/agent/image/ignition_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,11 @@ logdir /var/log/chrony`,
654654
assertExpectedFiles(t, ignitionAsset.Config, tc.expectedFiles, tc.expectedFileContent)
655655

656656
assertServiceEnabled(t, ignitionAsset.Config, tc.serviceEnabledMap)
657+
658+
assert.Len(t, ignitionAsset.Config.Passwd.Users, 1)
659+
assert.Equal(t, "core", ignitionAsset.Config.Passwd.Users[0].Name)
660+
assert.Contains(t, ignitionAsset.Config.Passwd.Users[0].SSHAuthorizedKeys, igntypes.SSHAuthorizedKey("my-ssh-key"))
661+
assert.Contains(t, ignitionAsset.Config.Passwd.Users[0].SSHAuthorizedKeys, igntypes.SSHAuthorizedKey("test-bootstrap-ssh-key\n"))
657662
}
658663
})
659664
}
@@ -801,6 +806,7 @@ func buildIgnitionAssetDefaultDependencies(t *testing.T) []asset.Asset {
801806
&tls.KubeAPIServerServiceNetworkSignerCertKey{},
802807
&tls.AdminKubeConfigSignerCertKey{},
803808
&tls.AdminKubeConfigClientCertKey{},
809+
&tls.BootstrapSSHKeyPair{Pub: []byte("test-bootstrap-ssh-key\n")},
804810
&gencrypto.AuthConfig{},
805811
&common.InfraEnvID{},
806812
&agentcommon.OptionalInstallConfig{},

0 commit comments

Comments
 (0)