# ============================================================ # SSH INSTALLER # ============================================================ $repo = "https://git.help-d.ru/helmut/auto-turning/raw/branch/main" $temp = "$env:TEMP\ssh_setup" Write-Host "`n========== SSH УСТАНОВКА ==========`n" -ForegroundColor Cyan # 1. Скачиваю установщик... Write-Host "1. Скачиваю установщик..." -ForegroundColor Yellow New-Item -ItemType Directory -Path $temp -Force | Out-Null Invoke-WebRequest -Uri "$repo/installers/OpenSSH.msi" -OutFile "$temp\OpenSSH.msi" -ErrorAction Stop Write-Host " ✓ Готово" -ForegroundColor Green # 2. Устанавливаю SSH... Write-Host "`n2. Устанавливаю SSH..." -ForegroundColor Yellow msiexec /i "$temp\OpenSSH.msi" /quiet /norestart Write-Host " ✓ Готово" -ForegroundColor Green # 3. Настраиваю авторизацию... Write-Host "`n3. Настраиваю авторизацию..." -ForegroundColor Yellow New-Item -ItemType Directory -Path "$env:USERPROFILE\.ssh" -Force | Out-Null "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHceolzaC/nnN14/lVqeXzcXcIANtQgJcIaFczLIchVo efgufk/admin@ISERVER" | Out-File "$env:USERPROFILE\.ssh\authorized_keys" -Force Write-Host " ✓ Готово" -ForegroundColor Green # 4. Настраиваю sshd_config... Write-Host "`n4. Настраиваю sshd_config..." -ForegroundColor Yellow $cfg = "C:\ProgramData\ssh\sshd_config" $c = Get-Content $cfg $c = $c -replace '^#Port 22', 'Port 2222' -replace '^Match Group administrators', '#Match Group administrators' -replace '^ AuthorizedKeysFile', '# AuthorizedKeysFile' $c | Set-Content $cfg Write-Host " ✓ Готово" -ForegroundColor Green # 5. Перезапускаю службу... Write-Host "`n5. Перезапускаю службу..." -ForegroundColor Yellow Restart-Service sshd -Force Write-Host " ✓ Готово" -ForegroundColor Green # 6. Чистка... Write-Host "`n6. Чистка..." -ForegroundColor Yellow Remove-Item $temp -Recurse -Force Write-Host " ✓ Готово" -ForegroundColor Green # Результат $ip = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object {$_.InterfaceAlias -notlike "*Loopback*"}).IPAddress Write-Host "`n========== ГОТОВО ==========" -ForegroundColor Green Write-Host "Подключайтесь: ssh -p 2222 $env:USERNAME@$ip" -ForegroundColor Cyan Write-Host "============================`n" -ForegroundColor Green