From 1c0c999cb83b15abedce367ab6cf5f5eb3ee9058 Mon Sep 17 00:00:00 2001 From: Derrick Martinez Date: Mon, 8 Jul 2024 16:37:16 -0700 Subject: [PATCH] Fix SSH Username on Google Cloud instances --- pkg/model/gcemodel/autoscalinggroup.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/model/gcemodel/autoscalinggroup.go b/pkg/model/gcemodel/autoscalinggroup.go index bf3c82d9a9614..35646697b6620 100644 --- a/pkg/model/gcemodel/autoscalinggroup.go +++ b/pkg/model/gcemodel/autoscalinggroup.go @@ -154,9 +154,13 @@ func (b *AutoscalingGroupModelBuilder) buildInstanceTemplate(c *fi.CloudupModelB } if len(b.SSHPublicKeys) > 0 { + sshUsername := "admin" + if strings.Contains(ig.Spec.Image, "ubuntu") { + sshUsername = "ubuntu" + } var gFmtKeys []string for _, key := range b.SSHPublicKeys { - gFmtKeys = append(gFmtKeys, fmt.Sprintf("%s: %s", fi.SecretNameSSHPrimary, key)) + gFmtKeys = append(gFmtKeys, fmt.Sprintf("%s: %s", sshUsername, key)) } t.Metadata["ssh-keys"] = fi.NewStringResource(strings.Join(gFmtKeys, "\n"))