Enable using saved host key
This commit is contained in:
parent
1d0d1aa20f
commit
f356858f02
@ -4,8 +4,11 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
gossh "golang.org/x/crypto/ssh"
|
||||
|
||||
"github.uio.no/torjus/apiary/config"
|
||||
|
||||
"github.com/gliderlabs/ssh"
|
||||
@ -34,6 +37,25 @@ func NewHoneypotServer(cfg config.HoneypotConfig, store store.LoginAttemptStore)
|
||||
PasswordHandler: hs.passwordHandler,
|
||||
ConnCallback: hs.connCallback,
|
||||
Handler: handler,
|
||||
Version: "OpenSSH_7.4p1 Debian-10+deb9u6",
|
||||
}
|
||||
|
||||
if cfg.HostKeyPath != "" {
|
||||
f, err := os.Open(cfg.HostKeyPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pemBytes, err := io.ReadAll(f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
signer, err := gossh.ParsePrivateKey(pemBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hs.sshServer.AddHostKey(signer)
|
||||
|
||||
}
|
||||
|
||||
return &hs, nil
|
||||
|
Loading…
Reference in New Issue
Block a user