feat: update host key

This commit is contained in:
2023-05-07 13:17:13 +08:00
parent 51eed1ae07
commit 2d0db4b8ef
2 changed files with 9 additions and 0 deletions

View File

@@ -132,6 +132,7 @@ func parseAllowedSshPubkeys() ([]gossh.PublicKey, error) {
for _, pubkeyLine := range pubkeySplitedLines {
pubkey := strings.TrimSpace(pubkeyLine)
// Comments starts with `#`
if len(pubkey) > 0 && !strings.HasPrefix(pubkey, "#") {
pubkey = strings.Split(pubkey, " ")[1]
pubkeyBytes, pubkeyBytesErr := base64.StdEncoding.DecodeString(pubkey)
@@ -149,6 +150,13 @@ func parseAllowedSshPubkeys() ([]gossh.PublicKey, error) {
}
func readHostKey() ([]byte, error) {
hostKeyEd25519File := "/etc/ssh/ssh_host_ed25519_key"
hostKeyEd25519FileBytes, hostKeyEd25519FileBytesErr := ioutil.ReadFile(hostKeyEd25519File)
if hostKeyEd25519FileBytesErr == nil {
log.Println("Found host key: ", hostKeyEd25519File)
return hostKeyEd25519FileBytes, nil
}
hostKeyEcdsaFile := "/etc/ssh/ssh_host_ecdsa_key"
hostKeyEcdsaFileBytes, hostKeyEcdsaFileBytesErr := ioutil.ReadFile(hostKeyEcdsaFile)
if hostKeyEcdsaFileBytesErr == nil {