sftpd: log fingerprints for used host keys

This commit is contained in:
Nicola Murino 2020-10-21 14:27:58 +02:00
parent 56bf8364cd
commit 6a8039e76a
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB

View file

@ -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)