diff --git a/honeypot/server.go b/honeypot/server.go index fdc48ea..ea32878 100644 --- a/honeypot/server.go +++ b/honeypot/server.go @@ -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