1
0
mirror of https://github.com/coalaura/up.git synced 2025-07-17 21:44:35 +00:00

improve serverside errors

This commit is contained in:
Laura
2025-06-20 20:57:47 +02:00
parent 64c78e71cc
commit 47567f4dac

View File

@ -3,6 +3,7 @@ package main
import (
"crypto/rand"
"encoding/base64"
"errors"
"os"
"path/filepath"
@ -25,6 +26,16 @@ func LoadAuthorizedKeys() (map[string]ssh.PublicKey, error) {
return nil, err
}
if _, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
return nil, errors.New("authorized_keys file is missing")
} else if os.IsPermission(err) {
return nil, errors.New("no permissions to read authorized_keys file")
}
return nil, err
}
keys := make(map[string]ssh.PublicKey)
data, err := os.ReadFile(path)