add post-login hook

a login scope is supported too so you can get notifications for failed logins,
successful logins or both
This commit is contained in:
Nicola Murino
2020-08-12 16:15:12 +02:00
parent a9e21c282a
commit aa0ed5dbd0
21 changed files with 220 additions and 129 deletions

View File

@@ -183,13 +183,14 @@ func CommandLog(command, path, target, user, fileMode, connectionID, protocol st
// A connection can fail for an authentication error or other errors such as
// a client abort or a time out if the login does not happen in two minutes.
// These logs are useful for better integration with Fail2ban and similar tools.
func ConnectionFailedLog(user, ip, loginType, errorString string) {
func ConnectionFailedLog(user, ip, loginType, protocol, errorString string) {
logger.Debug().
Timestamp().
Str("sender", "connection_failed").
Str("client_ip", ip).
Str("username", user).
Str("login_type", loginType).
Str("protocol", protocol).
Str("error", errorString).
Msg("")
}