From a8133263129c80d159b91b9b3abd7718e73c64fd Mon Sep 17 00:00:00 2001 From: Zebreus Date: Thu, 29 Oct 2026 00:50:29 +0100 Subject: [PATCH] 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 --- server/README.md | 3 ++- server/scripts/install_restore_task.ps1 | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server/README.md b/server/README.md index c0df5b6..3e5405d 100644 --- a/server/README.md +++ b/server/README.md @@ -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. diff --git a/server/scripts/install_restore_task.ps1 b/server/scripts/install_restore_task.ps1 index d1851dd..1b5873b 100644 --- a/server/scripts/install_restore_task.ps1 +++ b/server/scripts/install_restore_task.ps1 @@ -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