Fix user ssh key exporting and tests (#37256)

1. Make sure OmitEmail won't panic
2. SSH principal keys are not for signing or authentication
This commit is contained in:
wxiaoguang
2026-04-18 00:57:20 +08:00
committed by GitHub
parent 18064f772d
commit 279bf84066
4 changed files with 54 additions and 28 deletions
+3
View File
@@ -655,6 +655,9 @@ func ShowSSHKeys(ctx *context.Context) {
// "authorized_keys" file format: "#" followed by comment line per key
buf.WriteString("# Gitea isn't a key server. The keys are exported as the user uploaded and might not have been fully verified.\n")
for i := range keys {
if keys[i].Type == asymkey_model.KeyTypePrincipal {
continue // SSH principal keys are not for signing or authentication
}
buf.WriteString(keys[i].OmitEmail())
buf.WriteString("\n")
}