diff --git a/pkg/openstackbaremetalset/baremetalhost.go b/pkg/openstackbaremetalset/baremetalhost.go index 27f8ffe..a2c0c5d 100644 --- a/pkg/openstackbaremetalset/baremetalhost.go +++ b/pkg/openstackbaremetalset/baremetalhost.go @@ -70,7 +70,13 @@ func BaremetalHostProvision( // User data cloud-init secret if userDataSecret == nil { templateParameters := make(map[string]interface{}) - templateParameters["AuthorizedKeys"] = strings.TrimSuffix(string(sshSecret.Data["authorized_keys"]), "\n") + // Prepare ssh_authorized_keys list for template + splitKeys := strings.Split(strings.TrimSuffix(string(sshSecret.Data["authorized_keys"]), "\n"), "\n") + sshKeys := make([]string, len(splitKeys)) + for _, key := range splitKeys { + sshKeys = append(sshKeys, key) + } + templateParameters["AuthorizedKeys"] = sshKeys templateParameters["HostName"] = bmhStatus.Hostname //If Hostname is fqdn, use it if !hostNameIsFQDN(bmhStatus.Hostname) && instance.Spec.DomainName != "" { diff --git a/templates/openstackbaremetalset/cloudinit/userdata b/templates/openstackbaremetalset/cloudinit/userdata index ba5222d..4f8c0a8 100644 --- a/templates/openstackbaremetalset/cloudinit/userdata +++ b/templates/openstackbaremetalset/cloudinit/userdata @@ -4,7 +4,10 @@ hostname: {{ .HostName }} fqdn: {{ .FQDN }} users: - name: {{ .CloudUserName }} - ssh-authorized-keys: {{ .AuthorizedKeys }} + ssh_authorized_keys: +{{ range $ssh_key := .AuthorizedKeys }} + - {{ $ssh_key }} +{{ end }} sudo: ['ALL=(ALL) NOPASSWD:ALL'] shell: /bin/bash {{- if (index . "NodeRootPassword") }}