From 6a8039e76adca6e487d9997164414e3e982e1a0c Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Wed, 21 Oct 2020 14:27:58 +0200 Subject: [PATCH] sftpd: log fingerprints for used host keys --- sftpd/server.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sftpd/server.go b/sftpd/server.go index 7bf22db1..a5571ec3 100644 --- a/sftpd/server.go +++ b/sftpd/server.go @@ -301,7 +301,7 @@ func (c Configuration) AcceptInboundConnection(conn net.Conn, config *ssh.Server fs, err := user.GetFilesystem(connectionID) if err != nil { - logger.Warn(logSender, "", "could create filesystem for user %#v err: %v", user.Username, err) + logger.Warn(logSender, "", "could not create filesystem for user %#v err: %v", user.Username, err) return } @@ -555,14 +555,14 @@ func (c *Configuration) checkAndLoadHostKeys(configDir string, serverConfig *ssh for _, k := range c.HostKeys { hostKey := k if !utils.IsFileInputValid(hostKey) { - logger.Warn(logSender, "", "unable to load invalid host key: %#v", hostKey) - logger.WarnToConsole("unable to load invalid host key: %#v", hostKey) + logger.Warn(logSender, "", "unable to load invalid host key %#v", hostKey) + logger.WarnToConsole("unable to load invalid host key %#v", hostKey) continue } if !filepath.IsAbs(hostKey) { hostKey = filepath.Join(configDir, hostKey) } - logger.Info(logSender, "", "Loading private host key: %s", hostKey) + logger.Info(logSender, "", "Loading private host key %#v", hostKey) privateBytes, err := ioutil.ReadFile(hostKey) if err != nil { @@ -573,6 +573,8 @@ func (c *Configuration) checkAndLoadHostKeys(configDir string, serverConfig *ssh if err != nil { return err } + logger.Info(logSender, "", "Host key %#v loaded, type %#v, fingerprint %#v", hostKey, + private.PublicKey().Type(), ssh.FingerprintSHA256(private.PublicKey())) // Add private key to the server configuration. serverConfig.AddHostKey(private)