- Move oracle/migration-scripts/ to proxmox/lxc108-oracle/migration/ - Move oracle/roa/ and oracle/roa-romconstruct/ to proxmox/lxc108-oracle/sql/ - Move oracle/standby-server-scripts/ to proxmox/vm109-windows-dr/ - Move chatbot/ to proxmox/lxc104-flowise/ - Update proxmox/README.md with new structure and navigation - Update all documentation with correct directory references - Remove unused input/claude-agent-sdk/ files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
81 lines
4.0 KiB
PowerShell
81 lines
4.0 KiB
PowerShell
# Fix SSH Keys by recreating through SSH service
|
|
# Run as Administrator on DR VM (10.0.20.37)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
Write-Host "=== Fix SSH Keys via Service Method ===" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Step 1: Stop SSH service
|
|
Write-Host "[1/4] Stopping SSH service..." -ForegroundColor Yellow
|
|
Stop-Service sshd
|
|
Start-Sleep -Seconds 2
|
|
Write-Host " SSH service stopped" -ForegroundColor Green
|
|
|
|
# Step 2: Delete the problematic file while service is stopped
|
|
Write-Host "[2/4] Deleting old authorized_keys file..." -ForegroundColor Yellow
|
|
$authKeysFile = "C:\ProgramData\ssh\administrators_authorized_keys"
|
|
|
|
if (Test-Path $authKeysFile) {
|
|
# Try to take ownership first
|
|
takeown /F $authKeysFile /A
|
|
icacls $authKeysFile /grant Administrators:F
|
|
Remove-Item $authKeysFile -Force
|
|
Write-Host " Old file deleted" -ForegroundColor Green
|
|
} else {
|
|
Write-Host " File doesn't exist" -ForegroundColor Gray
|
|
}
|
|
|
|
# Step 3: Create new file with both keys
|
|
Write-Host "[3/4] Creating new authorized_keys file..." -ForegroundColor Yellow
|
|
|
|
$bothKeys = @"
|
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC88mX/oQnAoU54kazp6iYmmg91IR8pbnYV3aw5aJfSsiSBUjqo+XbvrWRvq//lli48k2kuNfq8olKrPvqKHcIccbcbgFrES5k2ErSyXjvbUlxuyHFRIfB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cpvjnU48altRRZvQzaJf3gIkG1lRGBgyW1n+WHe/7StIveYTVNFtx+fcnqB8gm9fZQxBp2WRbLNFpY/Qj+6BF66b1A2ZxH/3F9Z/6VT91EActOf+AMxjsI+09d7IRYIvzr8OxMPYOHU2bglp3o86xZEMUXfcjB8Sw/8KMsCjBp3ABEN9/bwv1496aw9IC67ZBQ2cDDfgdBej5DAkT4NS2XIx7wbM7sBtLYjcXMi7w== administrator@ROA-CARAPETRU2
|
|
"@
|
|
|
|
# Create the file
|
|
$bothKeys | Out-File -FilePath $authKeysFile -Encoding ASCII -NoNewline -Force
|
|
|
|
# Set permissions using icacls (more reliable than PowerShell ACL)
|
|
icacls $authKeysFile /inheritance:r
|
|
icacls $authKeysFile /grant "NT AUTHORITY\SYSTEM:(F)"
|
|
icacls $authKeysFile /grant "BUILTIN\Administrators:(R)"
|
|
|
|
Write-Host " New file created with correct permissions" -ForegroundColor Green
|
|
|
|
# Step 4: Start SSH service
|
|
Write-Host "[4/4] Starting SSH service..." -ForegroundColor Yellow
|
|
Start-Service sshd
|
|
Start-Sleep -Seconds 2
|
|
Write-Host " SSH service started" -ForegroundColor Green
|
|
|
|
# Verification
|
|
Write-Host ""
|
|
Write-Host "=== Verification ===" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
Write-Host "File permissions:" -ForegroundColor Yellow
|
|
icacls $authKeysFile
|
|
|
|
Write-Host ""
|
|
Write-Host "File content (number of lines):" -ForegroundColor Yellow
|
|
$lines = Get-Content $authKeysFile
|
|
Write-Host " Total keys: $($lines.Count)" -ForegroundColor White
|
|
|
|
foreach ($line in $lines) {
|
|
if ($line -match "ssh-rsa .+ (.+)$") {
|
|
Write-Host " ✓ $($matches[1])" -ForegroundColor Green
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "SSH service status:" -ForegroundColor Yellow
|
|
Get-Service sshd | Format-Table Name, Status, StartType -AutoSize
|
|
|
|
Write-Host ""
|
|
Write-Host "=== Setup Complete ===" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "Next: Test SSH connection from PRIMARY server" -ForegroundColor Cyan
|
|
Write-Host ""
|