Use an ssh-style format for logging login failures

merge-requests/30/head
Bob Mottram 2021-06-10 11:49:44 +01:00
parent 4d849f33a8
commit bb4afef15f
1 changed files with 7 additions and 2 deletions

View File

@ -245,7 +245,12 @@ def recordLoginFailure(baseDir: str, ipAddress: str,
currTime = datetime.datetime.utcnow()
try:
with open(failureLog, writeType) as fp:
fp.write(currTime.strftime("%Y-%m-%d %H:%M:%SZ") +
' ' + ipAddress + '\n')
# here we use a similar format to an ssh log, so that
# systems such as fail2ban can parse it
fp.write(currTime.strftime("%Y-%m-%d %H:%M:%SZ") + ' ' +
'ip-127-0-0-1 sshd[20710]: ' +
'Disconnecting invalid user epicyon ' +
ipAddress + ' port 443: ' +
'Too many authentication failures [preauth]\n')
except BaseException:
pass