The key that the website logs in with was written into the authorized_keys of the Administrator, which would have given everyone who has the website administrator rights on the box. It only gets access as the root user. The deploy script logs in as Administrator with the personal key of the deployer instead, from the agent or from -i. Co-Authored-By: Claude Code <noreply@anthropic.com>
18 lines
890 B
Batchfile
18 lines
890 B
Batchfile
@echo off
|
|
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. Run it as Administrator on the box, for example over RDP. The cleanup job puts the key
|
|
REM 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
|
|
> C:\msys2\home\root\.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 not defined SID goto :done
|
|
icacls C:\msys2\home\root\.ssh /grant *!SID!:(OI)(CI)F /t
|
|
icacls C:\msys2\home\root\.ssh /setowner *!SID!
|
|
:done
|
|
echo The SSH access is back.
|