feat: update host key
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
build_linux_x64.sh
|
||||||
allowed_keys
|
allowed_keys
|
||||||
simple-ssh-server
|
simple-ssh-server
|
||||||
.idea/
|
.idea/
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ func parseAllowedSshPubkeys() ([]gossh.PublicKey, error) {
|
|||||||
|
|
||||||
for _, pubkeyLine := range pubkeySplitedLines {
|
for _, pubkeyLine := range pubkeySplitedLines {
|
||||||
pubkey := strings.TrimSpace(pubkeyLine)
|
pubkey := strings.TrimSpace(pubkeyLine)
|
||||||
|
// Comments starts with `#`
|
||||||
if len(pubkey) > 0 && !strings.HasPrefix(pubkey, "#") {
|
if len(pubkey) > 0 && !strings.HasPrefix(pubkey, "#") {
|
||||||
pubkey = strings.Split(pubkey, " ")[1]
|
pubkey = strings.Split(pubkey, " ")[1]
|
||||||
pubkeyBytes, pubkeyBytesErr := base64.StdEncoding.DecodeString(pubkey)
|
pubkeyBytes, pubkeyBytesErr := base64.StdEncoding.DecodeString(pubkey)
|
||||||
@@ -149,6 +150,13 @@ func parseAllowedSshPubkeys() ([]gossh.PublicKey, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readHostKey() ([]byte, 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"
|
hostKeyEcdsaFile := "/etc/ssh/ssh_host_ecdsa_key"
|
||||||
hostKeyEcdsaFileBytes, hostKeyEcdsaFileBytesErr := ioutil.ReadFile(hostKeyEcdsaFile)
|
hostKeyEcdsaFileBytes, hostKeyEcdsaFileBytesErr := ioutil.ReadFile(hostKeyEcdsaFile)
|
||||||
if hostKeyEcdsaFileBytesErr == nil {
|
if hostKeyEcdsaFileBytesErr == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user