From f3e7f1637cec6a6bf4f783dc3d12473aa0d13124 Mon Sep 17 00:00:00 2001 From: Windneiro Date: Mon, 13 Apr 2026 16:29:26 +0500 Subject: [PATCH] .. --- ssh_install.ps1 | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 ssh_install.ps1 diff --git a/ssh_install.ps1 b/ssh_install.ps1 new file mode 100644 index 0000000..88bbf89 --- /dev/null +++ b/ssh_install.ps1 @@ -0,0 +1,50 @@ +# ============================================================ +# 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 \ No newline at end of file