diff --git a/.gitignore b/.gitignore index 982a1c5..d166b19 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +build_linux_x64.sh allowed_keys simple-ssh-server .idea/ diff --git a/simple-ssh-server.go b/simple-ssh-server.go index 13f27c4..90692fb 100644 --- a/simple-ssh-server.go +++ b/simple-ssh-server.go @@ -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 {