Keep the key of the website away from the Administrator account
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>
This commit is contained in:
parent
ac98212fa2
commit
fc7b75b930
1 changed files with 30 additions and 42 deletions
|
|
@ -1,16 +1,13 @@
|
|||
@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 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.
|
||||
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%
|
||||
|
||||
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:*,=!
|
||||
|
|
|
|||
Loading…
Reference in a new issue