bootstrapper: write host key & certificate

This commit is contained in:
miampf 2025-04-03 17:18:56 +02:00
parent 26df54949b
commit 150c3eea7b
No known key found for this signature in database
GPG Key ID: EF039364B5B6886C
3 changed files with 14 additions and 0 deletions

View File

@ -275,6 +275,14 @@ func (c *JoinClient) startNodeAndJoin(ticket *joinproto.IssueJoinTicketResponse,
return fmt.Errorf("writing ssh ca key: %w", err)
}
if err := c.fileHandler.Write(constants.SSHHostKeyPath, ticket.HostKey, file.OptMkdirAll); err != nil {
return fmt.Errorf("writing ssh host key: %w", err)
}
if err := c.fileHandler.Write(constants.SSHHostCertificatePath, ticket.HostCertificate, file.OptMkdirAll); err != nil {
return fmt.Errorf("writing ssh host certificate: %w", err)
}
state := nodestate.NodeState{
Role: c.role,
MeasurementSalt: ticket.MeasurementSalt,

View File

@ -46,6 +46,10 @@ const (
SSHCAKeySuffix = "ca_emergency_ssh"
// SSHCAKeyPath is the path to the emergency SSH CA key on the node.
SSHCAKeyPath = "/run/ssh/ssh_ca.pub"
// SSHHostKeyPath is the path to the SSH host key of the node.
SSHHostKeyPath = "/run/ssh/ssh_host_ecdsa_key"
// SSHHostCertificatePath is the path to the SSH host certificate.
SSHHostCertificatePath = "/run/ssh/ssh_host_cert.pub"
//
// Ports.

View File

@ -219,6 +219,8 @@ func (s *Server) IssueJoinTicket(ctx context.Context, req *joinproto.IssueJoinTi
ControlPlaneFiles: controlPlaneFiles,
KubernetesComponents: components,
AuthorizedCaPublicKey: ssh.MarshalAuthorizedKey(ca.PublicKey()),
HostKey: ssh.MarshalAuthorizedKey(hostKeyPub),
HostCertificate: ssh.MarshalAuthorizedKey(&certificate),
}, nil
}