# Setup SSH Keys for PRIMARY → Proxmox DR Transfer # Rulează acest script MANUAL pe PRIMARY ca Administrator # # Acest script: # 1. Generează chei SSH în profilul curent ($env:USERPROFILE\.ssh) # 2. Copiază cheia publică pe Proxmox host (10.0.20.202) # 3. Testează conexiunea SSH param( [string]$ProxmoxHost = "10.0.20.202", [string]$ProxmoxUser = "root" ) Write-Host "=========================================" -ForegroundColor Cyan Write-Host "SSH Key Setup pentru PRIMARY → Proxmox DR" -ForegroundColor Cyan Write-Host "=========================================" -ForegroundColor Cyan Write-Host "" $SSHDir = "$env:USERPROFILE\.ssh" $PrivateKeyPath = "$SSHDir\id_rsa" $PublicKeyPath = "$SSHDir\id_rsa.pub" # Verifică dacă cheia există deja if (Test-Path $PrivateKeyPath) { Write-Host "✓ SSH key deja există: $PrivateKeyPath" -ForegroundColor Green Write-Host " Voi folosi cheia existentă." -ForegroundColor Yellow } else { Write-Host "→ Generez SSH key pair..." -ForegroundColor Yellow # Creează directorul .ssh dacă nu există if (-not (Test-Path $SSHDir)) { New-Item -ItemType Directory -Path $SSHDir -Force | Out-Null } # Generează cheia SSH (fără parolă pentru automatizare) & ssh-keygen.exe -t rsa -b 4096 -f $PrivateKeyPath -N '""' -C "PRIMARY-RMAN-to-Proxmox" if ($LASTEXITCODE -eq 0) { Write-Host "✓ Cheie SSH generată cu succes!" -ForegroundColor Green } else { Write-Host "✗ Eroare la generarea cheii SSH" -ForegroundColor Red exit 1 } } Write-Host "" Write-Host "→ Citesc cheia publică..." -ForegroundColor Yellow $PublicKey = Get-Content $PublicKeyPath -Raw Write-Host "→ Copiez cheia publică pe Proxmox ($ProxmoxHost)..." -ForegroundColor Yellow Write-Host " IMPORTANT: Vei fi întrebat de parola root pentru Proxmox!" -ForegroundColor Cyan Write-Host "" # Copiază cheia publică pe Proxmox $command = "mkdir -p /root/.ssh && chmod 700 /root/.ssh && echo '$PublicKey' >> /root/.ssh/authorized_keys && chmod 600 /root/.ssh/authorized_keys && echo 'SSH key adăugat cu succes!'" & ssh "${ProxmoxUser}@${ProxmoxHost}" $command if ($LASTEXITCODE -eq 0) { Write-Host "✓ Cheie publică copiată pe Proxmox!" -ForegroundColor Green } else { Write-Host "✗ Eroare la copierea cheii pe Proxmox" -ForegroundColor Red Write-Host " Verifică dacă ai acces SSH la Proxmox cu parolă" -ForegroundColor Yellow exit 1 } Write-Host "" Write-Host "→ Testez conexiunea SSH fără parolă..." -ForegroundColor Yellow # Testează conexiunea & ssh -o StrictHostKeyChecking=no -i $PrivateKeyPath "${ProxmoxUser}@${ProxmoxHost}" "echo 'SSH connection OK'" if ($LASTEXITCODE -eq 0) { Write-Host "✓ Conexiune SSH funcționează fără parolă!" -ForegroundColor Green } else { Write-Host "✗ Conexiunea SSH nu funcționează" -ForegroundColor Red exit 1 } Write-Host "" Write-Host "=========================================" -ForegroundColor Green Write-Host "✓ Setup complet!" -ForegroundColor Green Write-Host "=========================================" -ForegroundColor Green Write-Host "" Write-Host "Cheia privată: $PrivateKeyPath" -ForegroundColor Cyan Write-Host "Cheia publică: $PublicKeyPath" -ForegroundColor Cyan Write-Host "" Write-Host "Scripturile de transfer vor folosi această cheie automat." -ForegroundColor Yellow Write-Host ""