Created
March 2, 2026 13:52
-
-
Save ciekawy/1a46030cf45074727b6452f0b054b428 to your computer and use it in GitHub Desktop.
WEB-9: SSH-only setup for Windows Server 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # WEB-9: SSH Setup Only (for when main script fails) | |
| # Run these commands one by one in PowerShell as Administrator | |
| Write-Host "Installing OpenSSH Server..." -ForegroundColor Cyan | |
| Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 | |
| Write-Host "Starting SSH service..." -ForegroundColor Cyan | |
| Start-Service sshd | |
| Set-Service -Name sshd -StartupType Automatic | |
| Write-Host "Configuring firewall..." -ForegroundColor Cyan | |
| New-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -DisplayName "OpenSSH Server" -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 | |
| Write-Host "Adding SSH public key..." -ForegroundColor Cyan | |
| $key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO9VR+9HrxMs+2NxN2h8Td6rCDP8eupti1BtqFK1pSdX coder@myfirst" | |
| $file = "C:\ProgramData\ssh\administrators_authorized_keys" | |
| New-Item -Path $file -ItemType File -Force -Value $key | |
| icacls $file /inheritance:r | |
| icacls $file /grant "SYSTEM:(F)" | |
| icacls $file /grant "BUILTIN\Administrators:(F)" | |
| Write-Host "Verifying SSH service..." -ForegroundColor Cyan | |
| Get-Service sshd | |
| Write-Host "" | |
| Write-Host "✅ SSH configured!" -ForegroundColor Green | |
| Write-Host "Test from Linux: ssh Administrator@46.224.201.14" -ForegroundColor Yellow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment