Fix SSH pubkey detection

This commit is contained in:
Thomas Miceli
2023-05-01 02:55:34 +02:00
parent 713b5d623e
commit 58d40e211f
6 changed files with 21 additions and 28 deletions

View File

@ -74,11 +74,12 @@ func sshKeysProcess(ctx echo.Context) error {
key.UserID = user.ID
_, _, _, _, err := ssh.ParseAuthorizedKey([]byte(key.Content))
pubKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(key.Content))
if err != nil {
addFlash(ctx, "Invalid SSH key", "error")
return redirect(ctx, "/settings")
}
key.Content = strings.TrimSpace(string(ssh.MarshalAuthorizedKey(pubKey)))
if err := key.Create(); err != nil {
return errorRes(500, "Cannot add SSH key", err)