From 758fc0b828b7a85b7488fcc35f6b9489fbc040dc Mon Sep 17 00:00:00 2001 From: Zebreus Date: Sun, 25 Oct 2026 13:35:29 +0100 Subject: [PATCH] Give the user their .ssh directory back in the recovery script Co-Authored-By: Claude Code --- server/scripts/restore_ssh_access.cmd | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/scripts/restore_ssh_access.cmd b/server/scripts/restore_ssh_access.cmd index 259c4c1..58d901e 100644 --- a/server/scripts/restore_ssh_access.cmd +++ b/server/scripts/restore_ssh_access.cmd @@ -2,6 +2,7 @@ REM Puts the SSH access back that a deleted home directory took with it: the key the website logs in with, in the REM home of the root user and in the home of the Administrator. Run it as Administrator on the box, for example REM over RDP. The cleanup job puts the key back by itself from then on. +setlocal EnableDelayedExpansion set KEY=ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJDweEH8bhZAHVaAedhTVDb2j/oMEn3vm97xCwCw9LC9 root@nowhere.wirs.ing cygwin-2222 if not exist C:\msys2\home\root\.ssh mkdir C:\msys2\home\root\.ssh @@ -10,4 +11,12 @@ if not exist C:\msys2\home\root\.ssh mkdir C:\msys2\home\root\.ssh if not exist C:\Users\Administrator\.ssh mkdir C:\Users\Administrator\.ssh >> C:\Users\Administrator\.ssh\authorized_keys echo %KEY% +REM The user owns their .ssh, so that they can add keys of their own. +for /f "tokens=5" %%i in ('findstr /b "root:" C:\msys2\etc\passwd') do set SID=%%i +set SID=!SID:*,=! +if defined SID ( + icacls C:\msys2\home\root\.ssh /grant *!SID!:(OI)(CI)F /t + icacls C:\msys2\home\root\.ssh /setowner *!SID! +) + echo The SSH access is back.