Keep the logs for years

The sshd log is rotated at a hundred megabytes instead of one, and the event
logs of windows are made that big as well: they are the only record of what
the box itself did, and twenty megabytes are not much with all the connections.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Zebreus 2026-10-29 00:50:29 +01:00
commit a813326312
2 changed files with 11 additions and 3 deletions

View file

@ -89,7 +89,8 @@ at the next run of the cleanup job, which happens within half an hour.
The server logs to `C:\ProgramData\kik-restore\sshd.log`. The log is appended to, not overwritten, because it is
the only trace of what the server did: a server that is restarted would otherwise take the evidence of an outage
with it. It is rotated when it grows past a megabyte.
with it. It is rotated when it grows past a hundred megabytes, which takes years. The event logs of windows are
made that big as well, so that they keep the history of the box itself for just as long.
Only keys may log in over SSH. The box stands in the open internet and both of its accounts have a password.

View file

@ -497,15 +497,22 @@ Set-Content -LiteralPath $sshdConfig -Encoding ascii -Value @(
# The sshd runs as SYSTEM from the protected copy, with opt/kik first on the path so its own DLLs and the session's
# programs (zsh, cat) are the protected ones. The log stays in the install directory, out of the user's reach.
# The log is appended to, not overwritten: it is the only trace of what the server did, and a server that is
# restarted would otherwise take the evidence of the outage with it.
# restarted would otherwise take the evidence of the outage with it. It is rotated at a hundred megabytes, which
# takes years to reach.
Set-Content -LiteralPath $sshdBat -Encoding ascii -Value @(
'@echo off',
'set PATH=C:\msys2\opt\kik;C:\msys2\usr\bin;%PATH%',
'rem Keep the previous log if it grew too big; the current one is appended to.',
'if exist C:\ProgramData\kik-restore\sshd.log for %%f in (C:\ProgramData\kik-restore\sshd.log) do if %%~zf GEQ 1048576 move /y C:\ProgramData\kik-restore\sshd.log C:\ProgramData\kik-restore\sshd.log.1',
'if exist C:\ProgramData\kik-restore\sshd.log for %%f in (C:\ProgramData\kik-restore\sshd.log) do if %%~zf GEQ 104857600 move /y C:\ProgramData\kik-restore\sshd.log C:\ProgramData\kik-restore\sshd.log.1',
'C:\msys2\opt\kik\sshd.exe -D -e >> C:\ProgramData\kik-restore\sshd.log 2>&1'
)
# The event logs of windows are made bigger as well: they are the only record of what the box itself did, and
# twenty megabytes are not much with all the connections.
foreach ($eventLog in 'System', 'Application', 'Security') {
wevtutil sl $eventLog /ms:104857600 | Out-Null
}
# The installation's own cygrunsrv sshd service would fight for port 22; the scheduled task owns the sshd instead.
Set-Service $service -StartupType Disabled -ErrorAction SilentlyContinue
Stop-Service $service -Force -ErrorAction SilentlyContinue