Skip to content

Commit b06e4cb

Browse files
authored
Merge pull request #219 from rancher-sandbox/pubkey-format
Ignore public keys that are not in ssh format
2 parents 93a80da + 86ab653 commit b06e4cb

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

examples/alpine.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
images:
2-
- location: https://github.com/lima-vm/alpine-lima/releases/download/v0.1.1/alpine-lima-std-3.13.5-x86_64.iso
2+
- location: https://github.com/lima-vm/alpine-lima/releases/download/v0.1.3/alpine-lima-std-3.13.5-x86_64.iso
33
arch: "x86_64"
4-
digest: "sha512:97099e0a0b3814799e0646d5ed5f1af5a7be77d8b8a59a51f5f65e1d8b5ec6fdc06a6e27be1c8344cce3614c201359cddff522e7959353f137adf6a85af938af"
4+
digest: "sha512:b2d2d2e4d9d15113b94e6f45ec46bb752fed639f062c52a87f065561e441fa2b271e53ce37e30add0a9ac287c0b65e66110c3fa79b2150b3da788559d139717a"
55

66
mounts:
77
- location: "~"

pkg/cidata/cidata.TEMPLATE.d/user-data

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ users:
1414
lock_passwd: true
1515
ssh-authorized-keys:
1616
{{- range $val := .SSHPubKeys}}
17-
- {{$val}}
17+
- "{{$val}}"
1818
{{- end}}
1919

2020
write_files:

pkg/sshutil/sshutil.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ func DefaultPubKeys(loadDotSSH bool) ([]PubKey, error) {
9090
}
9191
entry, err := readPublicKey(f)
9292
if err == nil {
93-
res = append(res, entry)
93+
if strings.ContainsRune(entry.Content, '\n') || !strings.HasPrefix(entry.Content, "ssh-") {
94+
logrus.Warnf("public key %q doesn't seem to be in ssh format", entry.Filename)
95+
} else {
96+
res = append(res, entry)
97+
}
9498
} else if !errors.Is(err, os.ErrNotExist) {
9599
return nil, err
96100
}

0 commit comments

Comments
 (0)