Skip to content

Commit

Permalink
Add a warning for ssh-rsa keys in authorized keys
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-heusel committed Mar 6, 2022
1 parent 4f767e7 commit 64b0105
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions breakglass.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,19 @@ func loadAuthorizedKeys(path string) (map[string]bool, error) {
result := make(map[string]bool)

s := bufio.NewScanner(bytes.NewReader(b))
for s.Scan() {
for lineNum := 1; s.Scan(); lineNum++ {
if tr := strings.TrimSpace(s.Text()); tr == "" || strings.HasPrefix(tr, "#") {
continue
}
pubKey, _, _, _, err := ssh.ParseAuthorizedKey(s.Bytes())
pubKey, comment, _, _, err := ssh.ParseAuthorizedKey(s.Bytes())

// This warning can be removed once the mentioned issue is resolved
if keyType := pubKey.Type(); keyType == "ssh-rsa" {
log.Print("Warning: You added a ssh-rsa key to your authorized keys, these do currently not work.")
log.Print("Further information: https://github.com/gokrazy/breakglass/issues/11")
log.Printf("Affected key: %s [...] %s (line %d)", keyType, comment, lineNum)
}

if err != nil {
return nil, err
}
Expand Down

0 comments on commit 64b0105

Please sign in to comment.