Skip to content

Commit 01305cf

Browse files
committed
rotate: Add key version to the public key
1 parent 32defca commit 01305cf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cmd/rotate.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io/fs"
1010
"os"
1111
"path"
12+
"path/filepath"
1213
"slices"
1314
"strconv"
1415

@@ -105,7 +106,8 @@ func generateKey(fn string) error {
105106
if err != nil {
106107
return fmt.Errorf("could not create SSH public key: %w", err)
107108
}
108-
if err := os.WriteFile(fn+".pub", ssh.MarshalAuthorizedKey(sshPub), 0o444); err != nil {
109+
ver := filepath.Base(fn)
110+
if err := os.WriteFile(fn+".pub", []byte(fmt.Sprintf("%s %s\n", ssh.MarshalAuthorizedKey(sshPub), ver)), 0o444); err != nil {
109111
return fmt.Errorf("could not write public key file %q: %w", fn+".pub", err)
110112
}
111113
return nil

0 commit comments

Comments
 (0)